Button on iPad not unloading game

I recently updated to a daily build (2012.749) and noticed that when I click the button on my iPad while in my game, whatever state my game is in is preserved.

At first glance, this is GREAT! But I later realized that in some cases, I do in fact want to close my game.

I’m wondering if anyone at Corona might be able to tell me if I can custom handle the button press and either trigger an exit of my game or allow for the game to continue to be loaded in the iPad memory (not exactly sure if that’s the correct way to describe that). If my game is on the title menu, I’d prefer to close it, when pressed. If it’s in the middle of a game, I’d prefer to save the state.

Apologies in advance if this is covered somewhere on the website that I missed.

Thanks!
[import]uid: 63276 topic_id: 22614 reply_id: 322614[/import]

There is an option on build.settings file, that goes into the plist options table for iOS that is:

settings = {  
 ...  
 iphone = {  
 ...  
 plist = {  
 ...  
 UIApplicationExitsOnSuspend = false,  
 ...  
 },  
 ...  
 },  
 ...  
}  

This allows you to define if your app state is saved or not.

There is another way to handle this that is the applicationSuspended event, to which you can attach a listener.

local function onSuspend(event) if (event.type == "applicationSuspend") then -- do stuff end end Runtime:addEventListener("system", onSuspend); [import]uid: 61899 topic_id: 22614 reply_id: 90219[/import]

Great!! Thanks a bunch CluelessIdeas. That’s exactly what I was looking for.

Kind Regards,
Scott D Brooks
[import]uid: 63276 topic_id: 22614 reply_id: 90324[/import]