Why are you using timers?  That seems needlessly complicated.
Use a game loop that keeps a constant frame rate.
Maintain state in your sprite objects, use the game loop to update this
state.
Then on a separate draw loop draw the sprite according to its state.

Then you dont have to worry about weird sync issues.

On Fri, Dec 2, 2011 at 5:45 AM, John Goche <johngoch...@googlemail.com>wrote:

>
> 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




-- 
~ Jeremiah:9:23-24
Android 2D MMORPG: http://solrpg.com/,
http://www.youtube.com/user/revoltingx

-- 
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