Jump to content

Problem with phaser time


Gods
 Share

Recommended Posts

I took a look at your code and I think you might be misunderstanding a Timer versus a TimerEvent. You seem to mix and match them. Specifically, your TimerEvent has the callback to endTimer but that will only be called one time, after 10s, because that is how you have the Event defined. Also, your "time" is defined as timerEvent.delay - timer.ms. Initially, that gives you what you want because the delay is 10s (as you configured the TimerEvent) and timer.ms=0 because the timer has just started. After the timerEvent fires and endTimer is called, the timer is stopped. From then on, the value of timer.ms will go further into the negative each time you stop and start it due to the way it is calculated internally. It seems from your code that what you need/want is a countdown timer. If that is the case, I believe that this forum discussion will probably give you the insight you need:

 

http://www.html5gamedevs.com/topic/1870-in-game-timer/

 

Good luck!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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