开发者

Saving the Users Game Scores on iOS

I am developing an iOS game and I have two questions. First, I am maintaining the levels information (scores, background image, etc) into a plist file. The first time that the app is launched, I copy the plist file from the resources directory to the documents directory (I need to write the user best scores into it). Exits a best way to maintaing this information? Second, if I make an update of the app, a开发者_Python百科dding new levels par example, how can I add the update new information without losing the current user scores?

Thanks for reading.


  1. A property list seems as good a way to keep track of high scores and such as any other. If you've already got that working, stick with it until you have a good reason to change.

  2. Your data file (indeed, the entire contents of the Documents directory) will be preserved when the user updates to a new version of the app.


AS Caleb said, a pList file is probably fine for saving high scores.

I'd like to add a bit about #2. You can just always re-use the same save file for simplicity, as long as you plan ahead for updates. This is a lot easier than trying to juggle different plist files for different versions.

When you create your game save plist file, just be sure to include a field for a save game format version number. That way, for future releases, you can open the save file, read the version number, and make any necessary adjustments to bring it up to the current version. This is extremely handy when players can essentially skip updates, downloading version 1 and 3 but skipping 2.


I agree with Caleb. It's best to have a little source code to help you.

I created this sample code that has both local and global support.


You might want to have a look at the NSUserDefaults class which provides basic management capabilities for storing app data. For more advanced data storage, CoreData is the recommended way to go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜