adolfintel / warpspeed

Animated and tweakable starfield for HTML5 Canvas
107 stars 22 forks source link

Question about handling multiple calls #4

Closed MaxTechnics closed 4 years ago

MaxTechnics commented 4 years ago

Hi, So i integrated WarpSpeed in a school project where the background gets activated after entering a button combination. This will call new WarpSpeed('kettlebg'). The thing is that afterwards, users are able to reenter the keys thus triggering new WarpSpeed('kettlebg') again. Does calling the function with the same id multiple times kill the previous instance? Or does it stack and keep using more and more resources?

adolfintel commented 4 years ago

It kills the previous instance and creates a new one https://github.com/adolfintel/warpspeed/blob/6f6068812048390b1dc02374f96d8b01070d3467/warpspeed.js#L22