by Jon (Updated on 2015-10-21)
Game Center is an Apple-operated service that records high scores, achievements, and charts these types of stats against those of friends and acquaintances.
Stencyl supports the high scores (leaderboards) and achievmements portions of Game Center. We don't support the multiplayer features.
In order to even test out Game Center functionality, you must set your game up on iTunes Connect and enable Game Center support for the game. Then, you must set up the leaderboards and achievements for your game.
This process is well-documented, but it constantly changes. For that reason, we'll point you to a 3rd-party article for setup, rather than put out something in-house that will fall out of date.
Read this article for details.
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.
Create a behavior that uses the following block (under Game > Mobile) and add it to your first/starting scene. When the Game Center bar appears, the player is considered to be signed in to Game Center.
Before you use any Game Center functionality, you should check that the player is signed-in. You can do this using the following event, which is found under Add Event > Mobile > Game Center > Game Center is started.
To submit a high score or achievement, use the blocks shown below. The ID is the Leaderboard ID you specified on iTunes Connect.
Block | Description | Where to Find |
---|---|---|
![]() |
ID = Leaderboard ID Score must be a number |
Game > Mobile |
![]() |
ID = Leaderboard ID Number must be between 0 - 100 inclusive |
Game > Mobile |
Note: Submitting a score or achievement does not pause the game. If you'd like to pause the game, consider using a Game Center event (Add Event > Mobile > Game Center > Game Center receives a score / achievement.)
Displaying the high score or achievements board involves the following blocks. As described below, you provide the Leaderboard ID that you entered into iTunes Connect.
Block | Description | Where to Find |
---|---|---|
![]() |
Shows the specified leaderboard (given a Leaderboard ID) | Game > Mobile |
![]() |
Shows all achievements for this game | Game > Mobile |
When you use these blocks, the leaderboard (or achievements page) will appear. The game will pause, so you don't need to worry about the game continuing to run while the leaderboards are being viewed.
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.
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.
Solution - You must enable Game Center Sandbox Mode. Consult the following page.
http://stackoverflow.com/questions/25238646/ios-8-beta-5-game-center-sandbox-wont-recognize-my-app