Game Pause

Does Corona automatically pause the game when the iPhone home button is pressed???

Is there a built in function in Corona or Director class which would automatically pause the game, or should I go through every timer, transition etc. and pause/resume them?
Thanks [import]uid: 59249 topic_id: 34035 reply_id: 334035[/import]

iOS will pause your application when the home button is pressed, forcing you to the background. It will then unpause it later if your app is restored from the background soon enough. (If not, your app will restart) In any case, it’s not a Corona feature, it’s done on the OS level.

There is no built-in pause function (kind of ridiculous when you think of how long Corona has been around and how pretty much every game needs this functionality).

There are however, a few community libraries (check shared code) that will keep track of all timers and/or transitions for you, and allow you to pause them all in a convenient way. That, along with pausing the physics engine, will “pause” an app. [import]uid: 36054 topic_id: 34035 reply_id: 135360[/import]

That is ridiculous - I would have thought a core function such as pausing would be higher on Corona’s priority list.

Confused about how to pause a transition, there’s lots of different tutorials.

Any one in particular you can recommend? [import]uid: 59249 topic_id: 34035 reply_id: 135448[/import]

http://www.coronalabs.com/blog/2012/05/15/handling-corona-system-events/

watch here…

to pause the game you always have to create you a function that puts you to sleep timers physics etc … [import]uid: 47941 topic_id: 34035 reply_id: 135449[/import]

Yes I get that you have to pause “timers physics etc…”

I was wondering if anyone can recommend a transition pause function. [import]uid: 59249 topic_id: 34035 reply_id: 135450[/import]

Look in code exchange there at lease one in there [import]uid: 7911 topic_id: 34035 reply_id: 135453[/import]

Hi @PuzzleRunner,
Just a few random thoughts on this. I have also thought about (wished for?) a “master pause” functionality in Corona for some time. However, the more I considered it, the more I realized it’s perhaps not as great in practice as it is in theory.

The obvious questions arise, “pause what?” Most people would agree that such things as timers, transitions, and sprites would be paused by this “master pause API”. But what about music and audio? Some users might want to pause that too (esp. on a phone if an incoming call is received)… but in terms of simple gameplay pause, I prefer my music to continue playing/looping. And what about some non-common timer cases? In a puzzle game, perhaps the developer wants a master timer to continue during pause, so the player can’t “cheat” by figuring out the puzzle during pause and then unpausing to complete it. My point is, a “one size fits all” pause API sounds better on paper than it does in reality. Yes, it’s tedious to pause everything manually in a game, but it almost seems necessary for each developer to solve this in his/her own methods, depending on how the app should function during pause.

Just some random thoughts on this. :slight_smile:

Brent
[import]uid: 200026 topic_id: 34035 reply_id: 135467[/import]

Fair point, but how about just pause transition?
Yes as advised from the above posts - I have found some examples on the code exchanges which I’m yet to try.
Thanks everyone for their help. [import]uid: 59249 topic_id: 34035 reply_id: 135471[/import]

@Brent You’re too worried about the edge cases. Corona has never been focused on handling all the edge cases when it comes to functionality. You just need something that the vast majority of people can use easily. In that context, one size fits (almost) all would be easy, just do this:

Corona.masterPause(bool includePhysics, bool includeTimers, bool includeTransitions, bool includeSprites, table exclude)

exclude = a table with a list of timer handles, transition handles, and sprites to exclude from pausing.

Corona.masterResume - Just resume anything that was paused. [import]uid: 36054 topic_id: 34035 reply_id: 135473[/import]

I too would like a master pause system too. I did have a pause function in my game but after frequent testing, some of my main objects disappear after pausing too much which is strange so I decided to opt out the pause function. It seems like pausing timers and transitions would cause a bug in your game. Each level in my game is about a minute or two and when you lose, you just restart the level so I’m not too worried. If I made an adventure game, then that’s a different story. I don’t remember having to pause an iOS game and not many people noticed that some games didn’t have a pause function. I guess it all depends on the game. [import]uid: 69494 topic_id: 34035 reply_id: 135492[/import]

iOS will pause your application when the home button is pressed, forcing you to the background. It will then unpause it later if your app is restored from the background soon enough. (If not, your app will restart) In any case, it’s not a Corona feature, it’s done on the OS level.

There is no built-in pause function (kind of ridiculous when you think of how long Corona has been around and how pretty much every game needs this functionality).

There are however, a few community libraries (check shared code) that will keep track of all timers and/or transitions for you, and allow you to pause them all in a convenient way. That, along with pausing the physics engine, will “pause” an app. [import]uid: 36054 topic_id: 34035 reply_id: 135360[/import]

That is ridiculous - I would have thought a core function such as pausing would be higher on Corona’s priority list.

Confused about how to pause a transition, there’s lots of different tutorials.

Any one in particular you can recommend? [import]uid: 59249 topic_id: 34035 reply_id: 135448[/import]

http://www.coronalabs.com/blog/2012/05/15/handling-corona-system-events/

watch here…

to pause the game you always have to create you a function that puts you to sleep timers physics etc … [import]uid: 47941 topic_id: 34035 reply_id: 135449[/import]

Yes I get that you have to pause “timers physics etc…”

I was wondering if anyone can recommend a transition pause function. [import]uid: 59249 topic_id: 34035 reply_id: 135450[/import]

Look in code exchange there at lease one in there [import]uid: 7911 topic_id: 34035 reply_id: 135453[/import]

Hi @PuzzleRunner,
Just a few random thoughts on this. I have also thought about (wished for?) a “master pause” functionality in Corona for some time. However, the more I considered it, the more I realized it’s perhaps not as great in practice as it is in theory.

The obvious questions arise, “pause what?” Most people would agree that such things as timers, transitions, and sprites would be paused by this “master pause API”. But what about music and audio? Some users might want to pause that too (esp. on a phone if an incoming call is received)… but in terms of simple gameplay pause, I prefer my music to continue playing/looping. And what about some non-common timer cases? In a puzzle game, perhaps the developer wants a master timer to continue during pause, so the player can’t “cheat” by figuring out the puzzle during pause and then unpausing to complete it. My point is, a “one size fits all” pause API sounds better on paper than it does in reality. Yes, it’s tedious to pause everything manually in a game, but it almost seems necessary for each developer to solve this in his/her own methods, depending on how the app should function during pause.

Just some random thoughts on this. :slight_smile:

Brent
[import]uid: 200026 topic_id: 34035 reply_id: 135467[/import]

Fair point, but how about just pause transition?
Yes as advised from the above posts - I have found some examples on the code exchanges which I’m yet to try.
Thanks everyone for their help. [import]uid: 59249 topic_id: 34035 reply_id: 135471[/import]

@Brent You’re too worried about the edge cases. Corona has never been focused on handling all the edge cases when it comes to functionality. You just need something that the vast majority of people can use easily. In that context, one size fits (almost) all would be easy, just do this:

Corona.masterPause(bool includePhysics, bool includeTimers, bool includeTransitions, bool includeSprites, table exclude)

exclude = a table with a list of timer handles, transition handles, and sprites to exclude from pausing.

Corona.masterResume - Just resume anything that was paused. [import]uid: 36054 topic_id: 34035 reply_id: 135473[/import]

I too would like a master pause system too. I did have a pause function in my game but after frequent testing, some of my main objects disappear after pausing too much which is strange so I decided to opt out the pause function. It seems like pausing timers and transitions would cause a bug in your game. Each level in my game is about a minute or two and when you lose, you just restart the level so I’m not too worried. If I made an adventure game, then that’s a different story. I don’t remember having to pause an iOS game and not many people noticed that some games didn’t have a pause function. I guess it all depends on the game. [import]uid: 69494 topic_id: 34035 reply_id: 135492[/import]