Jump to content

Multiple timers


mattbrand
 Share

Recommended Posts

I have 2 timers in my game - an overall game timer, which I display the value on the screen, and a cooldown timer, for when the player does an action, and they have to wait the cooldown duration until they can do another action.

My problem is that when I set the cooldown timer, the display of the overall game timer shows the cooldown timer, just briefly.

I set the main timer with:

gameTimer = game.time.events.add(Phaser.Timer.SECOND * 90, gameOver, this);

I display the main timer duration on the screen with:

timerText.setText("Time: " + formatTime(game.time.events.duration));

And I set the cooldown timer with another timer variable:

var timer = game.time.events.add(Phaser.Timer.SECOND * 0.2, resetCooldown, this);

I don't understand how to display the main game timer always, without the cooldown timer affecting it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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