app runs on iPad but only once....

Hi

I have a very simple app that appears to work and I have installed it on my iPad. The first time I run it on the iPad, it works OK. Then if I touch the desktop button and then open the app again, it starts in the state where it finished the first time, i.e. it doesn’t start again from the beginning. I don’t know how to make it start from the beginning again each time.

any help much appreciated.

cheers,

david

2 things to note:

Firstly, this is the expected behaviour on iOS apps. Apps run in the background, until the user double presses the home key, and then kills the process from the bar at the bottom. Some apps will restart completely when you suspend and resume the app (such as clash of clans), but in my experience most of them don’t.

Do you just want to do this for testing purposes? If so that is fine, if not then make sure there is a good reason for it. It is not very convenient for the user if they are force to restart the app every time they leave and come back.

Secondly, how to make it restart each time:

Add this to your build.settings file:

settings = {     iphone =     {         plist =         {             --this line kills the app whenever it is closed             UIApplicationExitsOnSuspend = true,         }     } }

Hi

Thanks for the reply. You are right about it not being convenient for the user if they are forced to restart. I ended up putting a “quit game” link in the bottom corner of the screen with an event listener on it. Unless they touch that, the app stays running.

quitGameListener = function(event)

    if ( event.phase == “began” ) then   

    os.exit()

    end

end 

You will find that using os.exit() gets your app rejected by Apple , as stated in the Corona docs. I believe that function is effectively the same as ‘force quitting’ an application, and may be seen as a crash. As I mentioned before, you must either force the app to quit every time via the build.settings file, or you leave it to the user to manually shut down the app by double tapping the home key. On Android you can use system.requestExit(), which brings up a “do you want to quit?” dialogue, but that is not available on iOS.

Ditto what @AlanPlantPot said!

Well, that’s where your game design skills come into play. You’ll need to add in your own UI for navigating back to the start. If you are using storyboard or director then have a praise menu or something with a button to go back to the main menu. If your game is fully contained in your main.lua file, then you will need to manually delete objects / reset positions and scores etc. You say “it’s not very convenient” that it is not automatically restated when the app is put into the background. Think about this far more inconvenient, and just as likely scenario: You are playing the game on a phone, just about top finish a level when the phone rings, and the app goes to the background. You end the call, go back to the game… and you’re right back at the start! Not very convenient at all.

>game on a phone, just about top finish a level when the phone rings, and the app goes to the background. You end >the call, go back to the game… and you’re right back at the start! Not very convenient at all.

That’s true. I’m new to apps and to devices in general. I don’t actually even own a device, but borrowed an iPad from work.

thanks for the info.

2 things to note:

Firstly, this is the expected behaviour on iOS apps. Apps run in the background, until the user double presses the home key, and then kills the process from the bar at the bottom. Some apps will restart completely when you suspend and resume the app (such as clash of clans), but in my experience most of them don’t.

Do you just want to do this for testing purposes? If so that is fine, if not then make sure there is a good reason for it. It is not very convenient for the user if they are force to restart the app every time they leave and come back.

Secondly, how to make it restart each time:

Add this to your build.settings file:

settings = {     iphone =     {         plist =         {             --this line kills the app whenever it is closed             UIApplicationExitsOnSuspend = true,         }     } }

Hi

Thanks for the reply. You are right about it not being convenient for the user if they are forced to restart. I ended up putting a “quit game” link in the bottom corner of the screen with an event listener on it. Unless they touch that, the app stays running.

quitGameListener = function(event)

    if ( event.phase == “began” ) then   

    os.exit()

    end

end 

You will find that using os.exit() gets your app rejected by Apple , as stated in the Corona docs. I believe that function is effectively the same as ‘force quitting’ an application, and may be seen as a crash. As I mentioned before, you must either force the app to quit every time via the build.settings file, or you leave it to the user to manually shut down the app by double tapping the home key. On Android you can use system.requestExit(), which brings up a “do you want to quit?” dialogue, but that is not available on iOS.

Ditto what @AlanPlantPot said!

Well, that’s where your game design skills come into play. You’ll need to add in your own UI for navigating back to the start. If you are using storyboard or director then have a praise menu or something with a button to go back to the main menu. If your game is fully contained in your main.lua file, then you will need to manually delete objects / reset positions and scores etc. You say “it’s not very convenient” that it is not automatically restated when the app is put into the background. Think about this far more inconvenient, and just as likely scenario: You are playing the game on a phone, just about top finish a level when the phone rings, and the app goes to the background. You end the call, go back to the game… and you’re right back at the start! Not very convenient at all.

>game on a phone, just about top finish a level when the phone rings, and the app goes to the background. You end >the call, go back to the game… and you’re right back at the start! Not very convenient at all.

That’s true. I’m new to apps and to devices in general. I don’t actually even own a device, but borrowed an iPad from work.

thanks for the info.