I need a timer for my game: when the user taps the screen, timer should pause and resume. Firstly, I tried to create a Timer once, MyTimerTask.cancel() to pause it, Timer.schedule(new MyTimerTask, ...) to resume it. But task manager shows that when the timer is paused, my application spends a huge amount of CPU (I develop under Android). As I understand, Timer executes empty queue. Now I .cancel() and .purge() the Timer and re-create it, along MyTimerTask. Is it right way to use Timer? Or I don’t understand something?
I need a timer for my game: when the user taps the screen, timer
Share
You could just add an if statement in you main game loop like:
And then when the user presses the pause button, you just set gameIsNotPaused to false/true.