by Jon (Updated on 2014-01-29)
- Starting Game Center
- Reporting High Scores
- Reporting Achievements
- Displaying Boards
Game Center is an Apple-operated service that records high scores, achievements, and charts these types of stats against those of friends and acquaintances. If you’re familiar with XBox Live, it’s similar.
For Stencyl, we’re primarily interested in getting games to display and submit high scores and achievements.
Starting Game Center
You must start the Game Center service through a behavior before using it. You want to do this as early as possible, preferably at the start of the game.
For example, create a behavior that uses the following block (located under Game > Mobile) and add it to your starting scene.
When the Game Center bar appears, the player is signed in.
You can check for this status using the following block, or you can use an Event (Add Event > Mobile > Game Center > Game Center is started) if you wish to be notified when this happens.
Reporting High Scores
To submit a score, use the block shown below (located under Game > Mobile). The ID is the Leaderboard ID you specified on iTunes Connect. The value should always be a number.
To submit an achievement, use the block shown below (located under Game > Mobile). Use the Achievement ID you specified on iTunes Connect. The value must be between 0 - 100 inclusive.
Displaying the High Score and Achievements Boards
Displaying the high score or achievements board involves the following blocks (located under Game > Mobile). Like before, in the leaderboard case, you want to specify the Leaderboard ID entered into iTunes Connect.
Using these blocks in a behavior will cause the boards to slide in.
Scores and Achievements not showing up?
Sometimes you have to wait a few hours for the data to show up in Game Center. This seems to afflict those who are far from Apple's server farms in the US, particularly Europe.
Another common cause is that sometimes, Game Center requires that at LEAST 2 players need to submit scores for the board to show up at all.
Game Center doesn't work at all in iOS 7 for my app. I canceled Game Center a few times.
Is a user has canceled Game Center 3 or more times, Game Center is permanently disabled for that app. The following post explains how to reverse this.