菜鸟教程小白 发表于 2022-12-12 23:05:14

ios - Cocos2d Gamecenter 因方向问题导致 iOS6 崩溃


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

<p> <a href="https://stackoverflow.com/questions/12612643/ios-6-game-center-crash-on-authentication" rel="noreferrer noopener nofollow">iOS 6 Game Center Crash on Authentication</a> </p>

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

<p>也试过了,但是不行<a href="https://stackoverflow.com/questions/12427979/gamecenter-authentication-in-landscape-only-app-throws-uiapplicationinvalidinter" rel="noreferrer noopener nofollow">GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation</a>我想是因为我使用的是 cocos2d 场景。</p>

<p>目前我正在实现此代码来解决问题,因为我别无选择。</p>

<pre><code>-(NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
</code></pre>

<p>我需要的解决方案是简单地打开游戏中心而不会崩溃,同时将代码锁定为横向(将所有 cocos2d 场景保持在横向)
任何帮助,将不胜感激。提前谢谢你。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>根据我的经验,我经历的大多数答案都解决了 cocos2d 1.x 上的问题。但是,我的游戏是使用 cocos2d 2.x 开发的,所以这里解决了我的问题:</p>

<p><strong>1) 我在目标设置中有这些设置:</strong></p>

<p> <img src="/image/kt6LT.png" alt="enter image description here"/> </p>

<p> <img src="/image/iTxZk.png" alt="enter image description here"/> </p>

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

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

<p> <a href="http://www.cocos2d-iphone.org/" rel="noreferrer noopener nofollow">http://www.cocos2d-iphone.org/</a> </p>

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

<p><strong>3) 在 AppDelegate.m 中,确保您没有使用 <code>CCDirector</code> 方法 <code>runWithScene:</code> 和 <code>pushScene:</code> 在 <code>-( bool )应用程序:didFinishLaunchingWithOptions:</code></strong></p>

<p>你想做的,只是使用这个功能:</p>

<pre><code>// 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
      ];
    }
}
</code></pre>

<hr/>

<p>只是推测,不要在 <code>- (BOOL)application: didFinishLaunchingWithOptions:</code> 中验证播放器。加载主场景后验证他,并调用 <code>onEnterTransitionDidFinish</code>。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Cocos2d Gamecenter 因方向问题导致 iOS6 崩溃,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/12876526/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/12876526/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Cocos2d Gamecenter 因方向问题导致 iOS6 崩溃