Jump to content

Restart / Stop a timer?


Recommended Posts

timer=game.time.events.loop(Phaser.Timer.SECOND, gameFunction(), this);. 




reset all values and create the timer again?


I do this :)

Thanks for this , i switched formats to this type when i couldn't figure it out but i'll probably go back to save a few lines haha.

Loop = game.time.create(true);Loop.add(Phaser.Timer.SECOND, function(), this);Loop.start();
Link to comment
Share on other sites

  • 2 years later...

I just implemented it the following way:

First, I store the timer itself and the loop in two different variables

timer = game.time.events;
loop = timer.loop(timeOut, fall, this);

Later in the game, when I need to change the pace of the loop, I use the loop object:

loop.delay -= speedUp;

But if I want to pause/resume, the I need to interact with the timer object:

function managePauseScreen(){
        pauseState = !pauseState;

These two object thus give me all the flexibility I need, and the solution is elegant!

Link to comment
Share on other sites


  • Recently Browsing   0 members

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