The one year game develpoment duel
Jul

1

2016

SpriteKit Save Files in Swift 3

Last year I wrote about saving game data in SpriteKit, and that code is now completely out of date. Swift 3 has brought about all sorts of fun changes, so it’s time for me to provided some updated code.

The general approach remains the same — conform save data to NSCoding and write to a plist file. The main changes / improvements are:

  • You have to manually create an empty DefaultFile.plist in your project directory
  • Uses new singleton implementation
  • You have to use encodeInteger / Double / Bool instead of just encodeObject
  • Swift 3 syntax changes

You can read my last post for more context, or jump straight to the gist below. First, code calling the GameData class.

Then, you can look at the GameData and Level class here:

2 of you did not hold your tongue!
  1. […] NOTE: This article has been updated. Refer to SpriteKit Saving with Swift 3 […]

  2. How to create a level ?


Speak Freely


Thank you

Your comment will be published once it has been approved.

Click here to see the pull request you generated.