How the system event Suspend work with Transition and Timer?

Hello guys

I would like some clarification on how to work the system event suspend on corona.

In my game I have about 30 modules and inside many of them use timer and transactions. I want to know if for every modules I create a method that in case of suspension put them all pause.

What coronaSdk does alone, what should I do?

What is the best way?

Each scene should be able to handle the conditions of a suspend event, but if you can generalise the logic so that the one library can perform save/restore functions then each scene can just call that when the event occurs.

Yes, there is more detail than this and it can get complicated, but I would start from that concept and work out where, in your particular case, it might be more difficult. Then come back with more specific questions.

thank you @horacebury

The game is the match 3 genre.

The modules use transactions for animations and timer to control the player of the screw creation time. Also in the main module using transactions to the elmenti fall. While using the timer to delay the call to some important functions. I noticed that if I suspend the game when I resume transactions are almost completely finished. for the main controls instead most often they are performed correctly, but sometimes it does not …

I hope I was clear. that’s why I asked the question. if you need something else I’d be happy to give it

The simple solution is put this in your code when the suspend happens.

– Cancel all transitions 

transition.cancel()

save game state 

exit level 

Then start the level over on resume. 

For timers you have to keep track of them yourself.   Then loop thru each one and cancel them.  

If you want to pause your whole game where it is and resume back it is a lot more complex but doable of course.  Is it worth it?  How annoyed is a 10 year old that has to start the level over after a phone call? 

thanks @laurasweet8888

But I think that my question is not clear. I do not want to delete timers or transactions. I want to put all of them paused. I want to know if I have to do it personally for each modules (as they are many) or there another way. However it would be good to know what makes the corona “alone”…

https://docs.coronalabs.com/api/library/transition/pause.html

The transition.pause() function pauses one of the following, depending on the passed parameter:

  • All transitions in progress, when called with no parameters.

Because of this I stopped using timers except for the main game timer.   If I want to time something I just use a transition instead.  

Thank you

Actually timers have the problems restrictions. Anyway thank you for your advice and your time.

I will use a similar solution at this point

Each scene should be able to handle the conditions of a suspend event, but if you can generalise the logic so that the one library can perform save/restore functions then each scene can just call that when the event occurs.

Yes, there is more detail than this and it can get complicated, but I would start from that concept and work out where, in your particular case, it might be more difficult. Then come back with more specific questions.

thank you @horacebury

The game is the match 3 genre.

The modules use transactions for animations and timer to control the player of the screw creation time. Also in the main module using transactions to the elmenti fall. While using the timer to delay the call to some important functions. I noticed that if I suspend the game when I resume transactions are almost completely finished. for the main controls instead most often they are performed correctly, but sometimes it does not …

I hope I was clear. that’s why I asked the question. if you need something else I’d be happy to give it

The simple solution is put this in your code when the suspend happens.

– Cancel all transitions 

transition.cancel()

save game state 

exit level 

Then start the level over on resume. 

For timers you have to keep track of them yourself.   Then loop thru each one and cancel them.  

If you want to pause your whole game where it is and resume back it is a lot more complex but doable of course.  Is it worth it?  How annoyed is a 10 year old that has to start the level over after a phone call? 

thanks @laurasweet8888

But I think that my question is not clear. I do not want to delete timers or transactions. I want to put all of them paused. I want to know if I have to do it personally for each modules (as they are many) or there another way. However it would be good to know what makes the corona “alone”…

https://docs.coronalabs.com/api/library/transition/pause.html

The transition.pause() function pauses one of the following, depending on the passed parameter:

  • All transitions in progress, when called with no parameters.

Because of this I stopped using timers except for the main game timer.   If I want to time something I just use a transition instead.  

Thank you

Actually timers have the problems restrictions. Anyway thank you for your advice and your time.

I will use a similar solution at this point