20.1 Scores and Achievements
Before getting too much further we need to decide what scores and achievements that you want to have for your game. For MineSweeper we will keep things fairly simple. We will set up a leader board for each game difficulty (easy, medium and hard) and keep track of the following achievements:
- Easy Winner (25 points) - Won an Easy Difficulty Game;
- Medium Winner (50 points) - Won a Medium Difficulty Game;
- Hard Winner (100 points) - Won a Hard Difficulty Game;
- Boom (25 points) - tapped a mine;
- Bad Luck (50 points) - tapped a mine on your first move;
- Decathlon (50 points) - play 10 games of any difficulty; and
- Centurion (100 points) - play 100 games of any difficulty.
20.2 iTunes Connect - Leaderboards
To set up the metadata for your App, log into your iOS developer account and go to iTunes Connect. We are assuming that you have already set up your App ID and provisioning profiles. If you haven't, look at Tutorials 12 and 13.
Click on the Manage your Applications link and then click on the App icon that you want to set up for Game Center. On the App Information screen you will see a button in the top right called Manage Game Center. Click on this and then enable your game (as either a single game or part of a group of games which shares scores and achievements). For MineSweeper we will just enable it as a single game, you can always change it to a group game later if you wish.
From the Game Center screen you can add leader boards and achievements. Remember that Leader boards which are live for any app version cannot be removed. This is true for achievements as well.
Click on the Add Leaderboard Button and then select add Single Leaderboard (You cannot create a combined leaderboard until you have two or more single leaderboards with the same score format type and sort order).
Figure 1. Add Language Screen.
Fill out the information for your leader board. The leaderboard reference name is an internal name that you must provide for each leaderboard. It is the name you should use if you search for the leaderboard within iTunes Connect. We used "Easy Difficulty" for our first leaderboard reference name.
The Leaderboard ID is a unique alphanumeric identifier that you create for this leaderboard. It can contain periods and underscores. We used the reverse URL style for ours (e.g. au.com.reefwing.minesweeper.easyDifficulty).
Then choose the score format for this app leaderboard and choose "High to Low" if you want highest scores displayed first or choose "Low to High" if you want the lowest scores displayed first. We select "Low to High" because a lowering your time to solve the grid is the objective.
Optionally, you can define the score range using 64-bit signed integers. The values must be between the long min (-2^63) and long max (2^63 - 1). Any scores outside of this range will be deleted. We don't define a score range for MineSweeper.
You must add at least one language for your leader board. For each language, you will have to provide a score format and a leaderboard name. Click on the Add Language button to bring up the screen to do this (see Figure 1).
The score format suffix will be added to the end of scores displayed on your leaderboard. Use this field to specify a singular suffix. This is optional, and is useful for clarifying the type of score your app uses. Examples include "point", "coin", or "hit".
Finally, you can assign an image to your leaderboard. The image must be a .jpeg, .jpg, .tif, .tiff, or .png file that is 512x512 or 1024x1024 pixels, at least 72 DPI, and in the RGB color space. Click the Save button and you are done.
Figure 2. Add an Achievement.
20.3 iTunes Connect - Achievements
Creating achievements is very similar to leaderboards. Click on the "Add Achievement" button to get started (Figure 2).
The Achievement Reference Name is an internal name that you must provide for each achievement. It is the name you should use if you search for the achievement within iTunes Connect (e.g. Easy Winner).
The Achievement ID is a unique alphanumeric identifier that you create for this achievement. It can contain periods and underscores. Once again we used the reverse URL style for ours (e.g. au.com.reefwing.minesweeper.easyWinner).
Point Value is the amount of points your achievement is worth. There is a maximum of 100 points per achievement and 1000 points for all achievements combined. The points we assigned to each achievement are shown in section 20.1. You will see that we have left lots of spare points in case we want to add additional achievements in the future.
Achievements marked as Hidden will remain hidden on Game Center until a player has achieved them. We wont hide any of our achievements.
For the "Achievable More Than Once" field, If you select Yes, users can accept Game Center challenges for achievements they have already earned.
Once you have filled out the above metadata for your App you need to add at least one language. For each language you need to add:
- Title: The localized title of this achievement as you would like it to appear in Game Center (e.g. Easy Winner).
- Pre-earned Description: The description of your achievement as it will appear to a Game Center user before they have earned it (e.g. Win at least one Mine Sweeper game on Easy Difficulty).
- Earned Description: The description of your achievement as it will appear to a Game Center user after they have earned it (e.g. Won at least one Mine Sweeper game on Easy Difficulty).
- An image for your achievement. The image must be a .jpeg, .jpg, .tif, .tiff, or .png file that is 512x512 or 1024x1024 pixels, at least 72 DPI, and in the RGB color space.
Click the Save Button and you are finished. Rinse and repeat for each one of your achievements.
In part 3 of the tutorial we will detail the code required in Lua and Objective C to tie these leaderboards and achievements to your game.