I'm making a relatively simple OpenGL ES based iPhone game. While testing on the iPhone 4 I've noticed that multitasking doesn't "work". Specifically the app is automatically terminated when it's put into the background state (I think this is due to making OpenGL calls in the background and/or not releasing some resources). Since the game is pretty simple... 20-30 short levels (about 1 min per level)... I'm wondering: In this case does multitasking really matter?
The entire game is OpenGL based and the UI is very snappy... so terminating the app, reloading it, and stepping through a few screens doesn't seem to be a big deal. What do you think? In this case does supporting multita开发者_StackOverflow中文版sking really matter?
It matters if you want your users to like you. What you can do is pause the game and stop any drawing calls when your app gets
- (void) applicationWillResignActive:(UIApplication *)application
and either stay paused or resume drawing in
- (void)applicationDidBecomeActive:(UIApplication *)application
You should do this even if your app isn't running on a multitasking device, because if you get a Push Notification or Local Notification, your app will be made inactive and you should pause the game.
As calmh references the docs, here's the paragraph:
Do not make any OpenGL ES calls from your code. You must not create an EAGLContext object or issue any OpenGL ES drawing commands of any kind. Using these calls will cause your application to be terminated immediately.
Not sure why you would want to draw in that case anyway.
As for the "stepping through a few screens"... Why not save the current state when exiting the app and restore this later anyway?
精彩评论