GameKitHelper:显示游戏中心排行榜

时间:2011-03-13 05:27:05

标签: cocos2d-iphone gamekit

我在我的Cocos2d游戏中使用GameKitHelper。在某些时候,我会想要显示排行榜,所以我这样做:

[[GameKitHelper sharedGameKitHelper] showLeaderboard];

但没有任何反应。我该怎么办?

1 个答案:

答案 0 :(得分:5)

显示gameKit助手?错了..

它应该是这样的:

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

此链接的引用:Link

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];