Jump to content

Phaser.Timer: dynamically change the property delay


Skell
 Share

Recommended Posts

Нow to dynamically change the property delay in object Phaser.Timer?

this.timer = this.game.time.create(false);this.timer.loop(1000, this.onTimer, this);this.timer.start();....this.timer.stop();this.timer.delay = 4000; // Access to the property delay is notthis.timer.start();

Now it is necessary to create Timer, to set a different value property delay...

Link to comment
Share on other sites

Delay is a property of the TimerEvent, not the Timer:

// create a new looping TimerEvent on the default game timer and return itthis.loopTimer = game.time.events.loop(1000, this.onTimer, this);// we can now modify its delaythis.loopTimer.delay = 500;

The Timer object should be thought of as a manager for TimerEvents, which are the actual objects you use to do the work.

Link to comment
Share on other sites

game.time.events.remove(this.loopTimer);

As game.time.events is an instance of Timer, or...

this.loopTimer.timer.remove(this.loopTimer);

Again, the Timer manages the events - and in the second instance, the TimerEvent itself keeps a reference to its managing Timer, so you can call remove from that reference.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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