iShellz Posted February 20, 2014 Share Posted February 20, 2014 Im lost im trying to restart my game that uses 4 timers using this format game.time.events.loop(Phaser.Timer.SECOND, gameFunction(), this);. Link to comment Share on other sites More sharing options...
AprendizEnLaRed Posted February 20, 2014 Share Posted February 20, 2014 timer=game.time.events.loop(Phaser.Timer.SECOND, gameFunction(), this);. this.timer.destroy();reset all values and create the timer again? I do this AlexArroyoDuque 1 Link to comment Share on other sites More sharing options...
iShellz Posted February 20, 2014 Author Share Posted February 20, 2014 timer=game.time.events.loop(Phaser.Timer.SECOND, gameFunction(), this);. this.timer.destroy();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 More sharing options...
Jerorx Posted February 22, 2016 Share Posted February 22, 2016 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; if(pauseState){ timer.pause(); }else{ timer.resume(); } } These two object thus give me all the flexibility I need, and the solution is elegant! Link to comment Share on other sites More sharing options...
Recommended Posts