As I started working on my secondwill-go-to-marketiPhone game, one of the most important improvements I made was moving configuration and level details to XML files from the very beginning. One of the differences between a great game and a mediocre game is flexibility, and storing details within XML files gives the gift of manifold flexibility (best of all, you can design a level or content format in XML, and then you can have non-programmers design content, and it's very easy to add content later on).
Fortunately, loading XML files on the iPhone is quite easy, once you pick up a couple of tricks.
The first step is to create a plist file:
Fileand then select
Scroll to the bottom of the list of templates, and select
From the templates, select
Name the properly list
settings.plist, and save it in your project.
Add whatever data you're interested in. For this example let's say that you leaveRootas a dictionary, and give it three keys:
- An array with the keylevels.
- A string with the keytitle.
- A number with the keyversion.
Now wherever you want to load the code, you just need to write a few simple lines that look like this:
One gotcha to watch out for: even if you place all your XML files in a directory in your project folder named
xmlonce you build you application.