Sign in to follow this  

Multiple timers

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 = * 90, gameOver, this);

I display the main timer duration on the screen with:

timerText.setText("Time: " + formatTime(;

And I set the cooldown timer with another timer variable:

var timer = * 0.2, resetCooldown, this);

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

Share this post

Link to post
Share on other sites

You actually have two timer events attached to one timer (Phaser's main timer). `` is changing depending on which event is coming up next.

I think you can calculate the remaining duration with, e.g.,

gameOverTimerEvent.tick - gameOverTimerEvent.timer._now

or maybe

gameOverTimeEvent.tick - game.time.time


Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.