13,134

Views

Beginner

Level

5

Comments

Game Center

by Jon (Updated on 2014-01-29)


Contents

  • Introduction
  • Starting Game Center
  • Reporting High Scores
  • Reporting 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. 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.

Note: For brevity, we’ve assumed that you’ve set up Game Center in iTunes Connect - otherwise none of the following will work. If you have not done that, read this article (starting at Step 5) 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.

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.

Note: Submitting a score 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)

 

Reporting Achievements

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.

Note: Submitting an 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 an achievement)

 

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.

 

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

 

Disclaimer: All articles are geared towards Stencyl 3.0 and above. 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!

5 Comments

Jon
All outstanding issues with Game Center (especially on iOS 7) were resolved a few months back.
0 7 months, 2 days 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 1 year, 3 months ago
Jon
Cleaned up and updated for Stencyl 3.0.
0 1 year, 4 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 2 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 2 years, 2 months ago

Sign In to Comment