cocos2d-xで縦画面にする

cocos2d-xのプロジェクトを作成するとデフォルトは横画面ですが、
縦画面への変更方法をメモ。

今回使用したバージョン

  • cocos2d-2.1beta3-x-2.1.1

iOS
RootViewController.mm

// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	//return UIInterfaceOrientationIsLandscape(interfaceOrientation);
	return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
	//return UIInterfaceOrientationMaskLandscape;
	return UIInterfaceOrientationMaskPortrait;
#endif
}

2箇所で、UIInterfaceOrientationXXXLandscapeをUIInterfaceOrientationXXXPortraitに変更します。


Android
AndroidManifest.xml

        <activity android:name=".OkahiroCocos2dX"
                  android:label="@string/app_name"
                  android:screenOrientation="portrait"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:configChanges="orientation">

Activityの設定に「android:screenOrientation="portrait"」を追加します。