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"; ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.