This recipe, along with the other two that follow, shows us how to read and parse simple data into Cocos2d scenes. Here we read a PLIST file to create a scene that depicts a desert with a few cacti.
#import <Foundation/Foundation.h> /* This returns the full absolute path to a specified file in the bundle */ NSString* getActualPath( NSString* file ) { NSArray* path = [file componentsSeparatedByString: @"."]; NSString* actualPath = [[NSBundle mainBundle] pathForResource: [path objectAtIndex: 0] ofType: [path objectAtIndex: 1]]; return actualPath; } @implementation Ch2_ReadingPlistFiles -(CCLayer*) runRecipe { //Initialize a read-only dictionary from our file NSString *fileName = @"scene1.plist"; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:getActualPath(fileName)]; //Process this dictionary...