Pause and Resume Game

Good day all,

I’m developing a runner game,

I want to implement pause and resume game so that the player can pause the game any time he feel.

In corona SDK, We can use suspend and resume in Hardware menu and achieve this

Please I need a code that we do exactly as  suspend and resume in  hardware menu work

Ie. If I click suspend the game will pause and when I click Resume, It will start again.

Thank you

The implementation of pause/resume depends greatly on your game architecture - essentially you’ll want to be pausing transitions (if you use them), animations and game state - anything that is processing.

My games tend to rely heavily on each class having an update loop (called from a main game loop), within this I simply perform a check on a member variable (obj.m_bPaused) to determine whether the logic is processed or not - in which case I jump out of the update function.

As segaboy writes, you need to make custom actions to handle it, totaly depending on your game logic. Hardware suspend/resume is when you send application to background or you suspend whole phone (you just freeze whole app then). Then you have no access to app! You cannot interact with it, until you bring it back so it’s in no meaning “pause”! When you pause, you still want to use app - just stop gameplay.

You need to pause timers, transitions, physics - whole logic you use in gameplay.

The implementation of pause/resume depends greatly on your game architecture - essentially you’ll want to be pausing transitions (if you use them), animations and game state - anything that is processing.

My games tend to rely heavily on each class having an update loop (called from a main game loop), within this I simply perform a check on a member variable (obj.m_bPaused) to determine whether the logic is processed or not - in which case I jump out of the update function.

As segaboy writes, you need to make custom actions to handle it, totaly depending on your game logic. Hardware suspend/resume is when you send application to background or you suspend whole phone (you just freeze whole app then). Then you have no access to app! You cannot interact with it, until you bring it back so it’s in no meaning “pause”! When you pause, you still want to use app - just stop gameplay.

You need to pause timers, transitions, physics - whole logic you use in gameplay.