2012-10-13 73 views
2

这已被要求在这里也被赋予了解决方案之前,但不工作这我有同样的问题,正确的Cocos2D的GameCenter崩溃iOS6的因定向

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; 
} 

我需要的解决方法很简单,打开GameCenter的不同时锁定的方向为横向的代码(把所有的cocos2d场景景观) 任何帮助,将不胜感激崩溃。先谢谢你。

+0

您使用的是cocos2d 1.x还是2.x? – Mazyod

+0

这个答案可以帮助you.http://stackoverflow.com/questions/12488838/game-center-login-lock-in-landscape-only-in-i-os-6 –

+0

尝试返回UIInterfaceOrientationMaskLandscape该方法的应用supportedInterfaceOrientationsForWindow –

回答

2

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

1)我的目标设置,这些设置:

enter image description here

enter image description here

人们在说我应该添加肖像支持,但那只是搞砸了我的轮换......

2)确保你正在使用最新的cocos2d 2.x!即使它处于测试阶段! (目前2.1 B2)

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

信任我,因为我认为测试是不稳定的,而我没有使用它,我有过许多错误和头痛。最终,升级到公测是我们推荐的cocos2d(不像Xcode的!)

3)在AppDelegate.m,请确保您使用的不是CCDirector方法runWithScene:pushScene:- (BOOL)application: didFinishLaunchingWithOptions:

要什么这样做,是只使用此功能:

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

而只是一种炒作,不认证球员。在主场景加载完成后对其进行身份验证,并调用onEnterTransitionDidFinish

+0

将尝试这一点,并告诉你如何去 –

2

我终于得到了游戏中心在iOS 6上工作,为我锁定的景观。

我把这段代码放在我的AppDelegate中。(不是视图 - 控制)

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

,我把这个在我看来Controller.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];