游戏中心排行榜将不会出现
问题描述:
好吧,我一直想在我的Cocos2D iPhone游戏显示游戏中心排行榜。 我进步了,我得到了这一段代码:游戏中心排行榜将不会出现
- (void) showLeaderboard {
tempVC=[[UIViewController alloc] init];
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController:leaderboardController animated: YES];
}
}
当我运行在模拟器中,我把它变成肖像模式,所以我知道发生了什么事情。但没有出现。没有排行榜出来。哪里不对?
- 我的应用程序已经与iTunes thingy链接。
- 我在游戏开始时已经成功验证。
- 我已经提交得分(带称为GameKitHelper一件很好的事)
答
转到AppDelegate.m和变化:
[window addSubview: viewController.view];
to
window.rootViewController = viewController;
然后调用它
GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper];
[gkHelper showLeaderboard];
这部作品cocos2d 1.0.0 RC1
+0
太棒了。谢谢Marcello。 – 2011-04-23 05:37:26
+0
Thx百万Marcello! – 2011-06-02 23:31:15
我试了你的代码在我的应用程序,它工作正常..我不知道wads错误w你的..有没有任何警告? – xuanweng 2011-03-17 03:49:38