Skip to main content
Participating Frequently
June 8, 2011
Question

iOS - Avoid Timer pause on app suspend

  • June 8, 2011
  • 2 replies
  • 757 views

I have a game that uses a tiemr to limit time for a completing a round.

When I navigte away from the game, the Timer 'pauses'...and this is undesireable.

Does anyone know how I can enable the Timer to continue, and thus seentially running out?

Any help apreciated - Thanks!

This topic has been closed for replies.

2 replies

Participating Frequently
June 8, 2011

Hello,

and this is undesireable.

Yes, but user could receive call from mom - application needs to handle going background and foreground

If application supports multitasking - one should always be prepared to save application state to restore it later,

regards,

Peter

Participating Frequently
June 8, 2011

What you could do is add listeners on the Event.ACTIVATE and Event.DEACTIVATE events. On deactivation store the value of getTimer() in a variable, then on activation check what the new getTimer() value is and reduce your remaining time by the difference.

getTimer() returns the number of milliseconds the program has been running

aphexyuriAuthor
Participating Frequently
June 8, 2011

Yes, I was also considering this but was hoping there was something baked in to handle this.