What’s New with Game Center in iOS 6

Note from Ray: This is the seventh iOS 6 tutorial in the iOS 6 Feast! This tutorial is an abbreviated version of one of the chapters from our new book iOS 6 By Tutorials. Ali Hafizji wrote this chapter – the same guy who’s written several Android tutorials for this site in the past. Enjoy! […] By Ali Hafizji.

Leave a rating/review
Save for later
Share

Learn about the new Challenges feature in GameKit in iOS 6!

Note from Ray: This is the seventh iOS 6 tutorial in the iOS 6 Feast! This tutorial is an abbreviated version of one of the chapters from our new book iOS 6 By Tutorials. Ali Hafizji wrote this chapter – the same guy who’s written several Android tutorials for this site in the past. Enjoy!

This is a blog post by iOS Tutorial Team member Ali Hafizji, an iOS and Android developer working at Tavisca Solutions.

You’ve probably heard of Game Center, the online multiplayer social gaming network introduced in iOS 4.1. It allows users to invite friends to play a game, start a multiplayer gaming session, track game achievements, and a lot more.

In addition to making implementing these standard social features much easier for developers, it also helps with a fundamental problem: app discovery. With over 1 million apps in the App Store today, the odds of a single user discovering your app can be frustratingly low. Game Center helps to solve this problem by allowing the user to see what games his/her friends are playing, thereby increasing the visibility of your game.

iOS 6.0 introduces new APIs in Game Center that not only continue to help your game gain visibility, but also increase user engagement. One such feature is the ability to send game challenges to friends, even those who don’t have the game installed. For example, a user could get a high score in your game and send a challenge to their friend saying “Hah, beat this!”

When the friend receives the challenge, they will see the message along with a direct link to download your app. It’s not hard to imagine how this could increase user retention manyfold! When you consider the large number of players using Game Center, this alone is a very good reason to add challenges to your games.

Before you can use challenges you need to use Game Center, so first this tutorial will take you through setting up Game Center and setting up a simple leaderboard, highlighting all the iOS 6 updates along the way.

Note: This tutorial assumes that you have prior knowledge of Cocos2D and have built games using it. If you are new to Cocos2D, you can read some of the many Cocos2D tutorials available on this website.

The MonkeyJump game

First download the starter project for this tutorial – MonkeyJump!

MonkeyJump is a simple side scroller written using my favorite game engine, Cocos2D. It was originally based on a simple game called CatJump developed for a Learning Cocos2D workshop, but I added some new features to make it more fun and added some cute new art from Vicki Wenderlich.

The main character of the game is, obviously, a monkey :] The objective of the game is to make the monkey cover the maximum possible distance while avoiding as many enemies as he can.

MonkeyJump is easy to play – even your mom could play! The player simply has to tap the screen to make the monkey jump over enemies. The game keeps track of the distance the monkey runs and uses it to determine the player’s score.

Try it out for yourself! Unzip the starter project, open it in Xcode and build and run. Try to see how far you can get! :]

Also go through the source code to understand how the layers and scenes work together.

Setting up Game Center

As mentioned earlier, before you to do anything with Game Center Challenges, you first have to set up your app to use Game Center! And to do that, you need to do three things:

  1. Create and set an App ID.
  2. Register your app on iTunes Connect.
  3. Enable Game Center features such as leaderboards.

Let’s go through each of these steps in turn. This will be old hat for many readers, but I promise we’ll go through these necessary tasks quickly.

Creating and setting an App ID

The first thing you need to do is create an App ID. To do this, log on to the iOS Dev Center and from there, select the iOS Provisioning Portal.

From the Provisioning Portal, select App IDs and create a new App ID. Use monkeyjump as the name and enter a bundle identifier – usually it’s good to use reverse DNS notation for a domain you control like com.ali.MonkeyJump (you can use your name if you don’t have a domain name).

Once you are done, click the Submit button. Open the MonkeyJump Xcode project, select project root, then the MonkeyJump target (if it’s not selected), and in the Summary tab change the Bundle Identifier to the identifier you created in the iOS Provisioning Portal.

Give the app a quick compile and run it on a device. If everything is in place the game will start right up. If it doesn’t, clean and build the project and try again.

Registering your app in iTunes Connect

The next step is to create a new app on iTunes Connect. Log in to iTunes Connect, switch to the application management screen, and click the Add New App button in the top left corner. (If you have both Mac and iOS developer accounts, you might have to select the type of app – which is iOS, of course)

On the first screen, enter MonkeyJump as the game name, 400 as the SKU number (this can be any number/word, so if you want you can set it to something else) and select the Bundle Identifier you created in the previous step.

When you are done entering all the values, press Continue. Follow the prompts and enter all the required details. Since you just need to get through these steps for the purposes of this chapter, fill in only the necessary values and be as brief as you want to be. ☺

You will need to upload a large app icon and a screenshot. To make the process easier, I have uploaded an iTunes resources file for you. You can extract the ZIP file and upload these to quickly finish the registration process.

When you’re done, click on the Save button and if everything went fine, you will be presented with the following screen:

Hurray! You have registered your app with iTunes Connect and completed the most perfunctory business. Now there are just a few more steps to activate Game Center. Don’t worry, the tough part is over. ☺

Ali Hafizji

Contributors

Ali Hafizji

Author

Over 300 content creators. Join our team.