Hello,

I have an android game which uses timers to update the screen sprites.
When the user wishes to pause the screen I have to know which timers
are pending and how long is missing before their expiration time. So this
means I have to maintain separate data structures for each Handler to
keep track of:

A. when the timer is set (timerSetTime) with System.nanoTime() and
B. how long before it expires (timerExpirationLength) so that

when the user pauses the game screen I cancel all timers
and then when the user unpauses for each paused timer I compute

unpauseTime = System.nanoTime()

and then reset each timer to timerExpirationLength - unpauseTime +
timerSetTime

and then when each timer expires unload the corresponding (timerSetTime and
timerExpirationLength)
data structure entry in the Handler subclass.

OK, I have described my solution to the problem. The android Handler system
does not seem
to provide a custom solution to this problem so I had to implement my own
code. If anyone has
a better solution to the problem of dealing with game state timers when the
game is paused (so
that they are saved as part of the game state) I'd like to hear your
alternative solutions.

Thanks,

John Goche

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to