2012-10-13 15 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];