0

I just asked this question for Google Play Services, but I also have a Game Center implementation for iOS. My game has two modes - normal and hard. At the end of a game I would like to be able to show the leaderboards for the current mode instead of showing all the leaderboards - that would be a confusing mess. Is this possible with Game Center?

Barodapride
  • 3,475
  • 4
  • 25
  • 36
  • 1
    Instead of me answering its best you look at the docs or an apple example because they go through it A-B I was just going to give you B since you didn't provide any code. Anyhow this is a great starting point https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/LeaderBoards/LeaderBoards.html#//apple_ref/doc/uid/TP40008304-CH6-SW44 – soulshined Dec 20 '14 at 08:05

1 Answers1

0

As mentioned by @soulshined, you'll want to first check out the docs in the Game Center Programming Guide, specifically the section on Displaying the Standard Leaderboard. It'll explain this much better than short answers here will.

Basically though, you'll first create an instance of a GKGameCenterViewController, tell it that you want to display a leaderboard, then specify which leaderboard to display, and finally present the new view controller to the user. Like so (based on some tweaked sample code from Apple):

- (void) showLeaderboard: (NSString*) leaderboardID
{
    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil)
    {
       gameCenterController.gameCenterDelegate = self;
       gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
       gameCenterController.leaderboardIdentifier = leaderboardID;
       [self presentViewController: gameCenterController animated: YES completion:nil];
    }
}
Josh Buhler
  • 26,878
  • 9
  • 29
  • 45