Displaying Achievements to Players
Problem
You need to display the achievements that the local player has received or is in the progress of receiving, using a graphical user interface.
Solution
Use the GKAchievementViewController class.
Discussion
Game Center can construct built-in achievements screens for your games. All you have to do is to build an iOS application that makes use of view controllers, covered in iOS 4 Programming Cookbook. For the remainder of this section, I assume you have created an application with one view controller inside a navigation controller.
In order to have Game Center construct an achievement screen for your iOS app, follow these steps:
Make sure that you have a view controller in your application (see iOS 4 Programming Cookbook). Also make sure your view controller conforms to the
GKAchievementViewControllerDelegateprotocol.Authenticate the local player (see Authenticating the Local Player in Game Center).
Allocate and instantiate an object of type
GKAchievementViewControllerand present it to the player using thepresentModalViewController:animated:instance method of your view controller.Implement the
achievementViewControllerDidFinish:delegate method of theGKAchievementViewControllerDelegateprotocol in your view controller.In the implementation of the
achievementViewControllerDidFinish:delegate method, dismiss your achievement view controller using the view controller’sdismissModalViewControllerAnimated:instance method.
Instances of the GKAchievementViewController ...