Game Development Community

multitasking, background suspend

by Sigit Sudwikatmono · in iTorque 2D · 01/08/2013 (4:50 pm) · 5 replies

Hi guys,

I've been reading up and searching through the forums about how to handle multi tasking and background suspend, but haven't been able to find a solution.
When my game switches to another app, and back, it restarts from scratch having to go through the 9+ seconds initial load. How abouts do I get it to not have to restart, and just resume where it left off? Is there a way to do it?

Our game, Burger Buzz was just released to the app store about 2 weeks ago, trying to really polish up the subtle qualities of a professional app by releasing an update.

Really appreciate any help provided. The forum has been a great help in our development process.

About the author

Recent Threads


#1
01/08/2013 (6:04 pm)
Is this the problem you're having?

http://www.garagegames.com/community/forums/viewthread/127168

Basically the oniPhoneResignActive TScript callback (triggered when you switch apps) could be shutting your game down. Or trying to: I didn't think that iOS apps could shut themselves down on purpose anymore.
#2
01/09/2013 (9:43 pm)
My experience has been that this happens when your app is using a lot of memory. If the iOS device needs more memory for the app it's switching to, then it's going to close yours.
#3
01/15/2013 (6:31 pm)
Hi guys sorry for the late respond and thanks for the replies.
I too have a feeling that it might be due to the memory use. I noticed that we have a low memory warning when running through Xcode. Are others able to have their game/app using it2d properly multitasking?

So now I guess would be, any advice on how to lower memory use? or handle it appropriately to allow for multitasking? I've tried various things such as combining our images all onto multiple large sprite sheets, hence reducing the number of data blocks used. Not sure how much that helps in terms of optimising though.
#4
01/15/2013 (10:40 pm)
The only way I dealt with it was by making my game save state as part of the oniphoneresignactive function. Then it reloaded that state when it relaunched. My initial load for the game isn't very long, though, so I didn't care whether the game got shut down or not.

Wish I could help with actual memory management, but I don't know much about it.
#5
01/16/2013 (12:44 pm)
In order to allow a texture to be unloaded, you have to set the t2dImageDatablock to AllowUnload = 1, and Preload = 0. This causes the texture to be unloaded whenever the number of objects using the datablock drops to 0.

It also causes the texture to load twice during level startup. Once when the datablock is loaded, then because you have no objects, it get dumped, then again when you make objects using the datablock. See my GLKit add-on (also in a community edition branch) for a fix to this.