April 2021
Beginner to intermediate
506 pages
11h 57m
English
In Chapter 15, Adding More Scenes and Saving the Game, you learned how to securely save and load game data by creating a custom GameData class. Rather than recreate the wheel, you’ll copy the resource file, GameData.swift, from the resources folder into the gloopdropproject. Note that this file is a bare-bones copy of what you made earlier.
Open Finder and drag the GameData.swift file into the Project Navigator; place it below the AdMobHelper.swift file.
Go back to Xcode, open the GameData.swift file, and below the line that reads // var propertyName: type = value, add the following:
| | var freeContinues: Int = 1 { |
| | didSet { |
| | saveDataWithFileName("gamedata.json") |
| | } |
| | } |
Here, you’re making sure ...
Read now
Unlock full access