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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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