Reputation: 3045
I'm about to work on a Objective-C game projects, and I'm curious to what's the options for getting constant data into the game. I've worked for many years as a Flash dev and in Flash I would just simply setup a class file and put in it objects like this...
static var arrowData:Object = {
elementType:"projectile",name:"arrow",sourceType:"library", imgSource:"arrow", imageSourceSub:"",cellsX:1, cellsY:1,
bounderyType:"none",bounderyLeft:0,bounderyRight:1200, bounderyTop:80, bounderyBottom:580,
position:{rotateToDir:false,positionType:"movieclip", randomX:false, randomY:false, endRandomX:600, endRandomY:400, startX:0, startY:0},
visual:{imgLabel1:"", imgNumFrames1:15,imgFramesLoop1:true,runOnFrame1:0,runOnFrameFN1:"",runOnLastFN1:""},
movement:{moveType:"arc", maxDistance:400, atTarget:"remove", target:"mouse", targetData1:"mouseX", targetData2:"none"},
physical:{physData:"spritesLayer"},
interactive:{interactionType:"rect", removeOnInteraction:true, interactionResult:"ingame", interactionData1:"badGuysArray", interactionData2:"projectileCollision"},
character:{damage:10}
};
I've Objects inside Objects, but there doesn't seem to be any clear way to do the same with Objective-C, so my questions are...
Upvotes: 1
Views: 145
Reputation: 41622
As the comment by @tc touched on, the common way to maintain groups of related info is in NSDictionaries (or their mutable cousins). Dictionaries can also nest. You have two ways to save these easily: as plists per comment or in the 'defaults' system. The latter is more restrictive on the types of data it stores. Apple also has a class that will convert between JSON and native objects. I have no experience with question 4 - hope others can answer that.
Upvotes: 1