O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

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 the PLIST file data

To save data to PLIST, we will take a look at how to create a high score table and save the data of the highest score achieved by a player.

Getting ready

All the necessary files are already there because whackamole_template.plist was already added in the last section.

How to do it…

We will create three functions: one to load the high scores, the second to add the high scores, and the third to delete the scores in the file.

The function to load highScore is as follows. We will create two global variables—hiScores and hiScore—of the NSMutableArray type and int:

//** saving to PLIST -(void) loadHiScores { //** Our template and file names NSString *templateName = @"whackamole_template.plist"; NSString *fileName = @"whackamole.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