Pausing and Resuming All Timers

I’ve been working out how to implement pause/resume in my code. I’ve seen the beebeclass approach, which users onEnterFrame, but I think an approach using timers themselves would be cleaner.

I’ve tried directly changing the internal _time variable within the timer, which seems to be the system time at which the timer will be triggered.

[lua] Key: _time Value: 1021 Key: _count Value: 1
Key: _listener Value: function: 0x1ced3920
Key: _delay Value: 1000
Key: _iterations Value: 3[/lua]

If so, then all timers can be simply paused by making this a huge number, and saving the remaining time in another field, _remaining.

Resuming could be accomplished by resetting _time to system.getTimer() + _remaining.

Could somebody from Ansca please explain if this should work?
[import]uid: 36578 topic_id: 11288 reply_id: 311288[/import]

Not too sure if it’ll be helpful but Karnak Games has a “Transition Manager” to aid in pausing and resuming transitions.

http://karnakgames.com/wp/2011/03/transition-manager-for-corona-sdk-pause-resume-and-manage-all-transitions-in-a-scene/ [import]uid: 27215 topic_id: 11288 reply_id: 41018[/import]

Looks like this will fix it, although I’ve not tried it yet.

http://developer.anscamobile.com/code/pausable-timers-and-transitions-speed-adjustment

I’m using Beebe’s pausable timers right now - they work well. [import]uid: 36578 topic_id: 11288 reply_id: 41417[/import]