crouzilles Posted March 18, 2015 Share Posted March 18, 2015 Hi, I have created a timer like this: // Create our Timer timer = game.time.create(false); // Set a event to occur after 20 seconds timer.loop(20000, do_stuff, this);I have setup the spacebar to pause or unpause the game like this: // add keyboard controls var pauseKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); pauseKey.onDown.add(toggle_pause)When the player hits the spacebar, the game gets paused or unpaused like this: function toggle_pause() { game.paused = !game.paused; if (!game.paused) { timer.resume(); } else { timer.pause(); } }When ever I pause the game let's say for 30 seconds, then unpause the game, the timer will not be called for another 50 seconds (20 seconds for timer + 30 seconds of pause time). I have tested this with shorter and longer pause times, I get the same effect (20 seconds of timer + N seconds of pause time). Am I using the timer wrongly or is this a bug?RegardsCrouz Link to comment Share on other sites More sharing options...
crouzilles Posted March 19, 2015 Author Share Posted March 19, 2015 Anyone? Link to comment Share on other sites More sharing options...
darkraziel Posted March 19, 2015 Share Posted March 19, 2015 Shouldn't it be like this? function toggle_pause() { game.paused = !game.paused; if (!game.paused) { timer.pause(); } else { timer.resume(); } }Also, have you tried pausing the game without manually pausing the timer? Link to comment Share on other sites More sharing options...
crouzilles Posted March 19, 2015 Author Share Posted March 19, 2015 Shouldn't it be like this? function toggle_pause() { game.paused = !game.paused; if (!game.paused) { timer.pause(); } else { timer.resume(); } }Also, have you tried pausing the game without manually pausing the timer?Pausing the game without pausing the timer did the trick, thanks darkraziel Crouz Link to comment Share on other sites More sharing options...
Recommended Posts