About Game Center

People love to play games. Games on the App Store are no exception—games continue to be the most popular category of apps on iOS. Games are inherently a social activity. Sometimes, this social interaction is part of the game itself, such as when the game provides competitive or cooperative multiplayer gameplay. But even for games intended for single-player experiences, players like to see and share their accomplishments.

Because social gaming is such an important part of the game-playing experience, Apple supports it directly with the Game Center service. Game Center allows a player’s devices to connect to the Game Center service and exchange information. The following figure shows several ways users can interact with Game Center.

../Art/GC_intro_2x.png

Each player performs different activities but all of them are interacting with Game Center:

At a Glance

Game Center is best viewed as a collection of interconnected components that provide features both to game developers and to end users:

For players to take advantage of Game Center in your game—and for your game to be visible in the Game Center app—you must explicitly add support for Game Center to your game. You do this by implementing authentication and then at least one other Game Center feature.

Some Game Resources Are Provided at Runtime by the Game Center Service

All apps include images and localized text inside of its bundle that are used to display the app’s user interface. The app loads these resources from the bundle as needed. When you design a Game Center-aware game, some of the resources you create are not stored in the bundle. Instead, those resources are uploaded to the Game Center service during development of your game. At runtime, your game downloads the resources from Game Center. The main reason for storing these resources on Game Center is that those resources are also used by the Game Center app. For example, when the Game Center app displays one of your game’s leaderboards, it downloads the resources you provided so that it displays the score data the same way as your game.

The requirement that some of your resources be provided to Game Center affects how you design, develop, and test your game.

Your Game Displays Game Center’s User Interface Elements

Game Kit provides many classes that present full-screen user interfaces to the player. Standard classes are provided to display leaderboards, achievements, and matchmaking screens. For example, the GKGameCenterViewController class provides the simplest way to display Game Center content in your game.

In iOS, these are provided as view controllers. A view controller in your game presents one of these view controllers when necessary. On OS X, the same classes are used, but Game Center provides the infrastructure required to display them in a window.

Game Kit also provides support for banners. A banner appears for a short time to display a message to the player. Game Kit automatically presents some banner messages to the player when certain events occur, but your game can use the GKNotificationBanner class to display your own messages.

Game Center Features Require an Authenticated Player

All of Game Center’s features require an authenticated player on the device, known as the local player. Before your game uses any Game Center features, it must successfully authenticate the local player. Most Game Center classes function only if there is an authenticated player, and those classes implicitly reference the local player. For example, when your game reports scores to a leaderboard, it always reports scores for the local player.

Your game must disable all Game Center features when there is not an authenticated player.

Leaderboards Require Your Game to Have a Scoring Mechanism

Leaderboards allow your game to post scores to the Game Center service. Players can view these scores by viewing a leaderboard in the Game Center app, but your game can also display the standard leaderboard interface with just a few lines of code. Or, if you'd rather customize the appearance of a leaderboard, your game can download the raw score data. You can create multiple leaderboards for your game and customize each with your game’s scoring mechanisms.

Leaderboard Sets Allow You to Manage Your Leaderboards

Combine leaderboards into leaderboard sets to logically group leaderboards for your game. Implementing leaderboard sets raises the number of leaderboards that your game is allowed to contain. Combine all of the leaderboards for a single level into a set or combine the high score leaderboard from each level into a set, the decision on how to combine your leaderboards is up to you.

Achievements Require Your Game to Measure Player’s Progress

An achievement is a specific goal that the player accomplishes within your game, such as “Find 10 gold coins” or “Capture the flag in less than 30 seconds”. As with leaderboards, a player views achievements within the Game Center app or in your game. Within the Game Center app, players can compare earned achievements with those earned by friends. Within your game, you can choose to display the standard user interface or you can download the raw data to create your own custom interface.

Challenges Allow Players to Challenge Each Other

A challenge is sent from one player to another. Each challenge is a specific goal that the challenged player must complete. When a challenge is completed, both the challenger and the challenged player are notified. Challenges are automatically provided in any game that supports either leaderboards or achievements. However, you can also take the extra step of implementing customized support for challenges directly in your game.

Matchmaking Requires Your Game Design to Incorporate Multiplayer Gaming

Matchmaking allows players interested in playing online multiplayer games to discover each other and be connected into a match. Game Center supports three kinds of matchmaking:

How to Use This Document

If you are new to developing Game Center-aware games, start by reading Developing a Game Center-Aware Game. This chapter describes the process for designing and implementing a game that supports Game Center. Then read Displaying Game Center User Interface Elements which describes common conventions for displaying Game Center’s user interface elements in your game. This topic is particularly important for OS X developers as it explains the infrastructure Game Kit provides for displaying Game Center content over your own user interface. iOS developers will find that Game Center conforms to the standard programming model for view controllers.

All developers must read Working with Players in Game Center to learn how to authenticate players in their game. Then, as necessary, read the other chapters to learn how to implement specific Game Center features.

Although this guide describes many aspects of communicating with Game Center and using Game Center’s networking features, it is not a reference for low-level networking design patterns. Game Kit provides some networking infrastructure, but to implement a real-time network game, you need to understand and be prepared to handle common networking problems such as slow networks and disconnects.

Prerequisites

Before attempting to create a Game Center-aware game, you should already be familiar with developing apps on whichever platform you are targeting:

Game Kit also relies heavily on delegation and block objects.

See Also

See Game Kit Framework Reference for details on the Game Kit framework.

The GKAuthentication sample demonstrates how to implement user authentication.

The GKLeaderboards sample demonstrates how to implement leaderboards.

The GKAchievements sample demonstrates how to implement achievements.

To learn how to code sign and provision your app to use Game Center, read App Distribution Quick Start.