【问题标题】:Game Center Achievements and Cocos2d游戏中心成就与 Cocos2d
【发布时间】:2013-07-16 11:43:48
【问题描述】:

我有一个单例类来处理我所有的游戏中心内容。我已将其设置为 GKAchievementViewControllerDelegate 的代表。

我调用下面的方法showAchievements

 - (void) showAchievements
 {
     GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
     if (achievements != nil)
     {
         achievements.achievementDelegate = self.delegate;
         [self.viewController presentModalViewController: achievements animated: YES];
     }
 }

我实现了以下

 - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)achievements
 {
     [self.viewController dismissModalViewControllerAnimated: YES];
 }

在调用 showAchievements 之前,我使用以下代码设置 self.viewController

 AppController* appDelegate = (AppController*)[[UIApplication sharedApplication] delegate];
    [GameCenterManager instance].viewController = appDelegate.window.rootViewController;

当我调用 showAchievements 时,应用程序崩溃并在控制台日志中显示以下内容。

Jul 16 12:36:28 imac-3 myApp[17103] <Info>: 12:36:28.287698 com.apple.AVConference: GKSConnSettings: set server: {
    "gk-cdx" = "17.173.254.218:4398";
    "gk-commnat-cohort" = "17.173.254.220:16386";
    "gk-commnat-main0" = "17.173.254.219:16384";
    "gk-commnat-main1" = "17.173.254.219:16385";
}

在我调用 showAchievements 时,用户已成功登录。

知道我在这里可能做错了什么吗?

【问题讨论】:

  • cocos2d 是从哪里来的?
  • 这可能是相关的。我如何获得根视图控制器是我认为问题的唯一地方,因为其他代码几乎是从苹果文档中剪切和粘贴的。任何熟悉 cocos2d 中视图结构的人都可以指出我的错误。同时它可能无关紧要。

标签: iphone cocos2d-iphone game-center gamekit


【解决方案1】:

我的怀疑是正确的,我试图以错误的方式访问 viewController。我应该一直使用 CCDirectorIOS 对象而不是 UIWindow 对象。

【讨论】:

    【解决方案2】:

    GKAchievementViewController 已弃用。尝试使用 GKGameCenterViewController。

    【讨论】:

      猜你喜欢
      • 2012-07-30
      • 1970-01-01
      • 2012-02-25
      • 2012-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      相关资源
      最近更新 更多