I am new to iphone ,Now i am doing a game in cocos2d.In that i need to save gamestate when it quits or terminates and resume the states.Anyone can give tutorials f开发者_C百科or doing that and also give me some instructions on how to do that.anyone can help me.......Thanks in advance (apologies for any grammar mistakes .....)
As far as I know there is no cocos2d specific way of doing this. However, you can probably implement your own solution by saving whatever variables you want out to a preferences file using the NSUserDefaults class.
As for where to trigger this load/save operation, take a look in your xxxxxxAppDelegate.m (xxxxxx is the name of your app) file generated by the cocos2d project template. There are a number of functions commented out in this file regarding different app events (starting, quitting, being sent to the background with the home button, and being resumed). Just uncomment the ones you are interested in, which is probably all of them, and call the functions that you wrote around NSUserDefaults.
精彩评论