As of late 2021, we are in the process of updating Stencylpedia and fixing up outdated & broken content. Thanks for your patience!

36,866

Views

Beginner

Level

7

Comments

Game Center

by Jon (Updated on 2015-10-21)


Contents

  • Introduction
  • Setting up Game Center on iTunes Connect
  • Starting Game Center
  • Reporting High Scores and Achievements
  • Displaying Boards
  • Troubleshooting

Introduction

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.

Setting up Game Center on iTunes Connect

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.

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.

Signing In

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.

start-game-center

Checking that the player is signed-in

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.

start-game-center-event

Reporting High Scores and Achievements

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
stencyl-high-score-block ID = Leaderboard ID
Score must be a number
Game > Mobile
stencyl-achievements-block 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 and Achievements Boards

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
stencyl-show-leaderboard-block Shows the specified leaderboard (given a Leaderboard ID) Game > Mobile
stencyl-show-achievements-block 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.

Troubleshooting

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.

http://stackoverflow.com/questions/18927723/reenabling-gamecenter-after-user-cancelled-3-times-ios7-only

Game Center doesn't work in iOS 8 while I'm testing it.

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

Print Article Edit Article How to Edit an Article
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!

7 Comments

dgcharlston
Seems like IOS 10 has made some major changes to this, they are phasing this out?
0 7 years, 11 months ago
EfrenStudios
Does this works on Android?
0 9 years, 4 months ago
Jon
All outstanding issues with Game Center (especially on iOS 7) were resolved a few months back.
1 10 years, 7 months ago
baberuth
I can't get the leaderboard to launch on the iPad without crashing my game. Any ideas?

Also, the leaderboard almost always goes to my default leaderboard instead of the leaderboard for the specified ID.

1 11 years, 4 months ago
Jon
Cleaned up and updated for Stencyl 3.0.
0 11 years, 5 months ago
Jon
That's correct. You use the ID of the board. It's coincidental that the names used above looked like real names, but were in fact IDs.
0 12 years, 1 month ago
h1rnz1lla
Hello!

I had no luck displaying the right Leaderboard with using its name, like described above. But using the ID of the board instead fixed the issue!


0 12 years, 2 months ago

Sign In to Comment