Skip to content

Instantly share code, notes, and snippets.

Last active July 1, 2016 21:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Example usage of saving GameData
/// User clicks on slot one, so we want to create a new save file for that slot
if GameData.sharedInstance.loadGame(saveFile: "One") {
/// An existing save file was there, progress as you need to
else {
/// A new save file was created, so start your game from a fresh state
/// User buys 100 gold += 100
/// User advances to level 2, so you want to update level data and save the file
/// Assumes you have handle on Level object already
level.completed = true
/// Then, I just replace the entire instance of the storage with the new level object.
/// More important when working with structs
GameData.sharedInstance.levelData?.levels[] = level
/// Call save to write the changes out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment