当排行榜在游戏中心关闭时,cocos2d点击被禁用

时间:2012-09-14 16:37:30

标签: cocos2d-iphone game-center

我显示游戏中心排行榜,但是当我点击完成按钮时,排行榜关闭。 但我无法点击屏幕上的任何按钮。

这是我的代码:

- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    CCLOG(@"leaderboardViewControllerDidFinish %@", viewController);
    [viewController dismissModalViewControllerAnimated:YES];
    [viewController.view removeFromSuperview];
    [viewController release];
    [[CCDirector sharedDirector] resume];
}

2 个答案:

答案 0 :(得分:1)

使用此代码。

Cocos2D 2.0

-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
    [app.navController dismissModalViewControllerAnimated:YES];
}

Cocos2D 1.0

-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [app.viewController dismissModalViewControllerAnimated:YES];
}

答案 1 :(得分:1)

我正在使用cocos2D 1.0

对不起,但您提供的代码不起作用。

我解决了这个问题。我只评论一行。 我失去了排行榜的近距离动画,但它确实有效。

- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    CCLOG(@"leaderboardViewControllerDidFinish %@", viewController);
    [viewController.view removeFromSuperview];
    [viewController release];    
    [[CCDirector sharedDirector] resume];
}