April 2021
Beginner to intermediate
506 pages
11h 57m
English
Before you jump into the code that reports scores to leaderboards, you may want to review the GameData.swift file. In this file, you’ll see there’s a wins property. This is the property you’ll use to track the player’s number of wins. If you switch to the GameOverScene.swift file, you’ll see the didMove(to:) method increments this value by one every time the player wins a game. So, when you report the number of wins to the leaderboard, you’ll actually be passing in the value saved in this property.
All right, let’s get to it.
Switch to the GameKitHelper.swift file. First, add a new static property to hold the Leaderboard ID string, placing it at the top of the class (for easy access):
| | // Leaderboard IDs |
| | static ... |
Read now
Unlock full access