How to Exit?

I have created an small game and used the close() function as my way to exit the game. This works perfectly in Codea however now that I have moved it to xcode and placed the game on my iPad it no longer works. Is there another function to close your application?

The home button? All kidding aside, no, you can’t force an app to close in Xcode. You could make an infinite loop though I guess and crash the app though. Edit: tried making an infinite loop, doesn’t seem to crash it though.

is there a way to simulate five fingers’ pinch in to exit?

Where do you want to exit to…?

like home button?

@firefox Why wouldn’t the user just press the home button? I think you can crash Codea by calling perspective(0) and then trying to draw something, if you really wanted a quit button, but most games just let you press the home button.

Apple guidelines don’t allow apps to exit - you have to press the home button (the five finger pinch of “app” death) is an OS gesture and you have no control over it.

Normally app’s respond to system events when they get interrupted (see the exported xCode source), but these don’t get passed through to Codea - it is possible but a pain to set up.

Ideally what you should do is allow your app to “persist” or “serialise” it’s data any time a major change takes place (ie something’s unlocked, high score entered, new player details entered etc) then it doesn’t matter as when your app starts you can interrogate the current save data and restore your app back to the point it was.

The only appstore app I’ve seen that did allow you to exit is “Desktop Dungeons” which is pretty much a straight Unity recompile of the Android, PC, Web version - I’m still surprised that Apple let that slip through as normally it would be grounds for rejection.

Now that you all say that I realize most apps don’t let you exit (sure would explain why it doesn’t work), I guess I will remove the exit button. Thanks!