Jump to content

Time loop is not working after reentering state


spinnerbox
 Share

Recommended Posts

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

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() constructor

cardTimer = new Phaser.Timer(gameObject, false);gameObject.time.add(cardTimer);

Can this time be interfering somehow?

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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