【问题标题】:GameKitHelper: Displaying Game Center leaderboardsGameKitHelper:显示 Game Center 排行榜
【发布时间】:2011-03-13 05:27:05
【问题描述】:

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

[[GameKitHelper sharedGameKitHelper] showLeaderboard];

但是什么也没发生。我该怎么办?

【问题讨论】:

    标签: cocos2d-iphone gamekit


    【解决方案1】:

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

    【讨论】:

    • 该代码应该放在哪里?因为在我的 Cocos2d 场景中,self 没有 presentModalViewController 方法。
    • 嗯,这很有趣:我的游戏是横向模式,当我运行该代码时,模拟器进入纵向模式,所以我可以知道发生了什么。但是根本没有出现排行榜。游戏继续正常运行……这是为什么呢?非常感谢您迄今为止的帮助!一些信息:我的应用程序已经链接到 iTunes 的东西。我的用户已通过身份验证。
    • 没关系!设法修复它。非常感谢;D!
    • @xuanweng:GameKitHelper 是我为我的书《Learn Cocos2D》写的一个包装类:learn-cocos2d.com/store/book-learn-cocos2d
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    相关资源
    最近更新 更多