Gods Posted March 16, 2015 Share Posted March 16, 2015 I have a problem with phaser time. When the time is over I want it to display "Done!". I also notice sometimes when I restart the timer it adds more time?https://jsfiddle.net/knz4aczh/ Link to comment Share on other sites More sharing options...
jerejigga Posted March 19, 2015 Share Posted March 19, 2015 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 More sharing options...
Recommended Posts