【问题标题】:Cocos2d Gamecenter Crashing iOS6 due to orientationCocos2d Gamecenter 因方向问题导致 iOS6 崩溃
【发布时间】:2012-10-13 20:04:39
【问题描述】:

在给出解决方案之前已在此处询问过此问题,但无法正常工作

iOS 6 Game Center Crash on Authentication

检查一下我有同样的问题。链接中的上述代码解决了它,GameCenter 工作,但现在 cocos2d 游戏旋转,这给游戏带来了问题。有没有人解决它或对此有任何解决方案

也试过这个,但我认为它不起作用GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation,因为我使用的是 cocos2d 场景。

目前我正在实施此代码来解决问题,因为我别无选择。

-(NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

我需要的解决方案是简单地打开游戏中心而不会崩溃,同时将代码锁定为横向(将所有 cocos2d 场景保持在横向) 任何帮助,将不胜感激。提前谢谢你。

【问题讨论】:

  • 你用的是cocos2d 1.x还是2.x??
  • 这个答案可能对你有帮助。stackoverflow.com/questions/12488838/…
  • 尝试为方法应用程序supportedInterfaceOrientationsForWindow返回UIInterfaceOrientationMaskLandscape

标签: ios cocos2d-iphone game-center


【解决方案1】:

根据我的经验,我经历的大多数答案都解决了 cocos2d 1.x 上的问题。但是,我的游戏是使用 cocos2d 2.x 开发的,所以这里解决了我的问题:

1) 我在目标设置中有这些设置:

人们说我应该添加纵向支持,但这只是搞砸了我的旋转......

2) 确保您使用的是最新的 cocos2d 2.x!即使它处于测试阶段! (目前为 v2.1 b2)

http://www.cocos2d-iphone.org/

相信我,我有很多错误和头痛,因为我认为 beta 不稳定,我没有使用它。最终,始终建议使用 cocos2d 升级到 beta(与 Xcode 不同!)

3) 在 AppDelegate.m 中,确保您没有在 - (BOOL)application: didFinishLaunchingWithOptions: 内使用 CCDirector 方法 runWithScene:pushScene:

你想做的,只是使用这个功能:

// This is needed for iOS4 and iOS5 in order to ensure
// ... blah blah blah
- (void)directorDidReshapeProjection:(CCDirector *)director {
    if (director.runningScene == nil) {
        // Add the first scene to the stack. blah blah...
        // and add blah
        [director runWithScene:[LanguageScene node]];
    }
}

只是一个猜测,不要在- (BOOL)application: didFinishLaunchingWithOptions: 中验证玩家。加载主场景后对他进行身份验证,并调用onEnterTransitionDidFinish

【讨论】:

  • 试试这个并告诉你进展如何
【解决方案2】:

我终于让 Game Center 在 iOS 6 中工作,并为我留下了锁定的风景。

我将此代码放在我的 AppDelegate 中。 (不是视图控制器)

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  return (UIInterfaceOrientationMaskAll);
}

我把它放在我的视图控制器中。m

- (void)authenticateLocalPlayer {
     GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
     localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
    {
        if (viewController != nil)
        {
            [self presentViewController:viewController animated:YES completion:nil];  
        }
     };
}

我还发现了排行榜和成就视图控制器的更新。

[self presentViewController:achievements animated:YES completion:nil];
[self presentViewController:leaderboardController animated:YES completion:nil];

[self dismissViewControllerAnimated:NO completion:nil];

【讨论】:

    猜你喜欢
    • 2012-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    相关资源
    最近更新 更多