Saturn
Saturn

Reputation: 18159

GameKitHelper: Displaying Game Center leaderboards

I am using GameKitHelper for my Cocos2d game. At some point, I will want to display the leaderboards, so I do this:

[[GameKitHelper sharedGameKitHelper] showLeaderboard];

But nothing happens. What should I do?

Upvotes: 0

Views: 2519

Answers (1)

xuanweng
xuanweng

Reputation: 1939

Show gameKit helper? Its wrong..

it should be this:

- (void) showLeaderboard
{
    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
    if (leaderboardController != nil)
    {
        leaderboardController.leaderboardDelegate = self;
        [self presentModalViewController: leaderboardController animated: YES];
    }
}

reference at this link: Link

The code for cocos2d..

UIViewController* _tmpView = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    GKLeaderboardViewController* gclb = [[GKLeaderboardViewController alloc] init];
gclb.leaderboardDelegate = self;
    [[[CCDirector sharedDirector] openGLView] addSubview:_tmpView.view]; 
    [_tmpView presentModalViewController:gclb animated:NO];

Upvotes: 5

Related Questions