spinnerbox Posted April 6, 2015 Share Posted April 6, 2015 I have this loop in my GameScreen state: timeCounter = function () { timeElapsed += 1; levelTimeText.update(); if (cardGroup.countLiving() === 0) { gameObject.time.events.stop(false); showLevelCompletePanel(); }}GameScreen = { init: function () { gameObject.time.events.loop(TIMER_DELAY, timeCounter); gameObject.time.events.start(); }}So each time I enter GameScreen state the loop should start counting, but it works only the first time. So I enter first time. All works and then when I enter GameScreen again, the loop doesn't start at all. What do I do wrong, or what could be happening with the loop? Link to comment Share on other sites More sharing options...
spinnerbox Posted April 6, 2015 Author Share Posted April 6, 2015 No it really stucks to 0 when I reenter GameScreen. It doesn't rerun it somehow. I have another custom timer created with Phaser.Timer() constructorcardTimer = new Phaser.Timer(gameObject, false);gameObject.time.add(cardTimer);Can this time be interfering somehow? Link to comment Share on other sites More sharing options...
spinnerbox Posted April 6, 2015 Author Share Posted April 6, 2015 And what is the difference between game.time.events.paused and game.time.events.running?As if these properties do not cancel each other. For example when I run game.time.events.pause(), does paused becomes true and running becomes false? Edit: Use "paused" property since it gets true/false. "running" property always stays true even when I use functions pause() or resume(). Not sure why though. Link to comment Share on other sites More sharing options...
Recommended Posts