Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Why does my game restart when I minimize and reopen it?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 blueshogun96   Members   


Posted 21 March 2014 - 02:26 AM

I haven't found much of anything to help me solve this problem, and debugging it is a pain because it doesn't happen when debugging remotely.  Let's say I pressed the home button and minimize the app.  applicationDidEnterBackground gets called, yes.  Is this where I'm supposed to save all of my game data and write it to the app's private data directory and load it when it comes back to the foreground?  All of my game's information is stored in a series of linked lists, and saving it would be easy enough I guess.


Another thing, does all of the app's memory get deallocated when it's minimized?  Should I deallocate everything to avoid memory leaks?  I find iOS not to be very straightforward in this regard.  Any advice is appreciated.  Thanks.



Follow Shogun3D on the official website: http://shogun3d.net

Posted Image Posted Image Posted Image Posted Image

"Yo mama so fat, she can't be frustum culled." - yoshi_lol

"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.

#2 Buster2000   Members   


Posted 21 March 2014 - 05:43 AM

When the app enters the background you should save state because the user may close the app by double tapping the home button and swiping up.

#3 C0lumbo   Members   


Posted 21 March 2014 - 10:47 AM

A long time ago, before iOS's 'multitasking', games would often save the entire game state on a suspend event, so that when the app is reopened you can restore the player to the exact position, be it mid-level, deep in the front end menus, or whatever.


These days, for most titles, it's not worth the effort. Just save any user progress as soon as it occurs, if the user suspends your app and tries to return to it, usually the OS will restore your app to the foreground as if nothing has happened. In the event that the OS decided to kill your app to reclaim the RAM, or the user manually killed your app, it doesn't matter much because you will have saved the progress fairly recently.


The only thing I would normally bother doing is to pause the game. One exception is that if your game is pushing the device's memory usage to the limit, then you should make an effort to free a decent chunk of memory on suspend (textures are quite easy to remove/reload), otherwise, the OS is very likely to close your app (particularly bad if your app has links to safari or the app store or something, the user follows the link from within your game, returns to the game only to find it has crashed!).


Here's the relevant doc from Apple: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.