Phil
Phil

Reputation: 3045

Method for getting data into game with Objective-C

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

  1. Is there any way to do the same as the above in Objective-C?
  2. What are the other methods for getting data into Objective-C? XML?
  3. How do iOS game devs usually store their constant game data?
  4. I'm going to be using the parse hosting service with this project, are there options for using that to store the data and loading it from there?

Upvotes: 1

Views: 145

Answers (1)

David Hoerl
David Hoerl

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

Related Questions