2012-05-06 62 views
2

我讀的每一個網頁都告訴我編輯我的「GameConfig.h」文件。在我的項目目錄中沒有這樣的文件,如果我嘗試導入它,我得到一個錯誤。如何在不編輯這個虛幻的頭文件的情況下更改我的默認方向?如何在Cocos2D中強制縱向模式?

回答

3

你沒有說你正在使用哪個版本的cocos2d,但是因爲你沒有GameConfig.h文件,我會猜測你正在使用2.0rc。

如果是這樣的話,看在AppDelegate.m,你會發現:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 

更改景觀爲縱向,所以你現在有:

return UIInterfaceOrientationIsPortrait(interfaceOrientation); 

你的遊戲則只有自動旋轉之間兩個肖像方向。

+0

我做了這個 但沒有發生場景 –

3

在cocos2d iPhone V3,您可以通過初始設置調用設置的方向,就像這樣:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    [self setupCocos2dWithOptions:@{ 
            CCSetupTabletScale2X: @(YES), 
            CCSetupScreenOrientation: CCScreenOrientationPortrait 
            }]; 
    return YES; 
} 
+0

也在項目設置>常規>部署信息>'設備方向'>檢查'肖像'和'顛倒' – chunkyguy

0

在cocos2d V3你在你的AppDelegate設置在didFinishLaunchingWithOptions方法如常:

[self setupCocos2dWithOptions:@{ 
           CCSetupShowDebugStats: @(YES), 
           CCSetupScreenOrientation: CCScreenOrientationPortrait, 
    }]; 

(我省略了更多的選擇)

,並在聲音在你的項目的Info.plist「支持的接口方向」或「蘇導航界面方向(iPad)「設置縱向而不是橫向(這是iPad的默認設置)。

相關問題