Game Development Reference
In-Depth Information
-(void) showAchievements
{
if (isGameCenterAvailable == NO)
return;
GKAchievementViewController* achievementsVC =
[[GKAchievementViewController alloc] init];
if (achievementsVC != nil)
{
achievementsVC.achievementDelegate = self;
[self presentViewController:achievementsVC];
}
}
This is very similar to showing the leaderboard view in Listing 14-11 . Once more, the
GameKitHelper class also has to implement the proper protocol, named
GKAchievementViewControllerDelegate :
@interface GameKitHelper : NSObject < GKLeaderboardViewControllerDelegate,←
GKAchievementViewControllerDelegate>
The protocol requires the GameKitHelper class to implement the achieve-
mentViewControllerDidFinish method, which is also strikingly similar to the
one used by the leaderboard view controller:
-(void) achievementViewControllerDidFinish:(GKAchievementViewController*)viewControl
{
[self dismissModalViewController];
if ([delegate respondsToSelector:@selector(onAchievementsViewDismissed)])
{
[delegate onAchievementsViewDismissed];
}
}
You can see an example of the achievements view in Figure 14-6 , in which one
achievement is already unlocked. To show the achievements view in landscape mode,
refer to the example I presented in the previous heading about leaderboards.
 
Search Nedrilad ::




Custom Search