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...
kieve Posted March 16, 2015 Share Posted March 16, 2015 You double posted, but I'll reply to this one: Working fiddle: https://jsfiddle.net/hshL1x96/ Timers default "autoDestroy" to true. When you call "stop()" on the timer, it gets destroyed.You need to add the timer event again. Thus, you also need to update the "onDown" context.Simply change like so: timer = game.time.create(false);...game.input.onDown.add(this.restart, this);...restart: function () { timer.stop() timerEvent = timer.add(Phaser.Timer.SECOND * 1, this.endTimer, this); timer.start();} Link to comment Share on other sites More sharing options...
Gods Posted March 16, 2015 Author Share Posted March 16, 2015 You double posted, but I'll reply to this one: Timers default "autoDestroy" to true. When you call "stop()" on the timer, it gets destroyed. Simply change the construction to this: timer = game.time.create(false);not sure why it double posted maybe my internet flaked out. How can I delete a thread? alsoI changed it to false but still the bugs are there. When I go out of browser window and go back in and press the canvas to reset timer it adds time. When the timer is over it doesn't display "Done!"https://jsfiddle.net/knz4aczh/2/ Link to comment Share on other sites More sharing options...
kieve Posted March 16, 2015 Share Posted March 16, 2015 I updated my post with a more comprehensive solution. Link to comment Share on other sites More sharing options...
Gods Posted March 16, 2015 Author Share Posted March 16, 2015 I updated my post with a more comprehensive solution.Thanks it works but I am not sure why the time displayed gains when you leave browser and go back in to reset even tho its still 5 seconds. Tested on Safari so not sure if you see that Link to comment Share on other sites More sharing options...
Recommended Posts