Jump to content

Timer not working on 2.0.4


Luis Fonseca
 Share

Recommended Posts

Hi,

 

I'm using the following code (Typescript) to create a timer and fire an event, but nothing happens.

 

Any idea what might be wrong?

private timer:Phaser.Timer;...this.timer = new Phaser.Timer(this.game, false);this.timer.add(counter, this.onTimerComplete, this);this.timer.start();private onTimerComplete():void{	console.log("Timer complete");}

 

Link to comment
Share on other sites

if you want to have control, use this approach:

var timer = game.time.create(false);timer.add(counter, onTimerComplete, this);timer.start();

I don't know why you code is not working. Perhaps some additional setup is required. I'm going to see the sources now  <_<

 

EDIT:

timers created using factory are automaticaly updated like this:

this._timers[this._i].update(this.now)
Link to comment
Share on other sites

The other approach doesn't work because the Timers update method never gets called. Either create it via the factory, or in your States update method call Timer.update directly (passing in the current timestamp).

 

Also note that creating one directly means it won't pause on game-pause events, etc. For that you should use the factory.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...