16 November 2007

How Mac Games Should Save

Putting on my GameHouse hat, I’d like to post on how games should save their state. (I often receive games that do it wrong.)

Games should not save state within the game bundle.

Games should not save state next to the application.

Both will fail if the game is run from a read-only volume (such as a disk image), or if the user doesn’t have write permissions to the /Applications folder (where someone may have installed the game).

I recommend saving to ~/Library/Preferences (or a folder therein). Locate this with FSFindFolder if you’re not using CFPreferences or NSPreferences.

Why not ~Library/Application Support? I figure most games track options such as sound effect and music volume. These are definitely preferences. Apple says of ~/Library/Application Support: “This directory should never contain any kind of user data.” And saved games are definitely user data.

So I’d say: anything the game saves goes in ~/Library/Preferences. Additional levels, downloaded user avatar images, etc. would go in ~/Library/Application Support.

No comments: