O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving data into a PLIST file

For the next three recipes, we have three small games that need to have their hi-scores persisted. In this recipe, we see a whack-a-mole game that will use a PLIST file to maintain a list of hi-scores.

Saving data into a PLIST file

Getting ready

Please refer to the project RecipeCollection01 for full working code of this recipe. For the sake of brevity all game logic has been omitted from the following code.

How to do it...

Execute the following code:

#import "ActualPath.h" @implementation Ch2_SavingDataPlist -(CCLayer*) runRecipe { [self loadHiScores]; return self; } -(void) loadHiScores { //Our template and file names NSString *templateName = @"whackamole_template.plist"; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required