Search code examples
javascripteaseljscreatejs

How to Reset the Ticker in CreateJS


I am working on a game using createjs. But I am stuck in a situation. My game has the the logic for timed mode. The game should reset every 30 seconds. But for some reasons I am unable to achieve that. I am getting the time lapsed as follows:

var time_elapsed = createjs.Ticker.getTime(true);

For resetting I am using:

createjs.Ticker.reset();

I am unable to reset the Ticker to 0 after 30 seconds.

Here is the fiddle for this.

Any help would be appreciated.

Thanks.


Solution

  • I took a quick look in the source-code: You need to set createjs.Ticker._inited = false; before you use another createje.Ticker.init();

    However this is a "private" attribute, so this might have some side-effect, I updated your fiddle here: http://jsfiddle.net/Dmk3v/4/

    A more elegant way to solve your issue would probably be to use your own counter just to capture the elapsed times and reset this one instead of resetting the createjs.Ticker