cocos2d-x의 화면 방향 (종횡)은 설정만으로는 끝나지 않으므로 정리해 둡니다.

소개



cocos2d-x로 프로젝트를 만든 직후에 먼저 할 화면의 종횡 설정을 정리합니다.
설정을 괴롭히는 것만으로는 안되기 때문에, 토탈로 무엇을 하는지를 정리해 둡니다.
※「이것도 필요하잖아!」등의 붙어 있으면 코멘트해 주세요.

화면의 가로세로 설정



iOS



프로젝트의 [General]를 열고 [Device Orientation]를 설정합니다.
Portrait : 세로
Landscape : 옆 (좌우는 어느 쪽이라도 괜찮습니다)


그런 다음 이전 버전 지원 (iOS7 이전)을 위해 다음 코드를 추가하는 것이 좋습니다.

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 UIInterfaceOrientationMaskAllButUpsideDown;  //横
    return UIInterfaceOrientationMaskPortrait;  //縦
#endif
}

안드로이드



프로젝트에서 [AndroidManifest.xml][android:screenOrientation] 를 설정합니다.
portrait : 세로
landscape : 옆

AndroidManifest.xml
<activity android:name="org.cocos2dx.cpp.AppActivity"
                 android:label="@string/app_name"
                 android:screenOrientation="portrait" //★この部分★
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                 android:configChanges="orientation">

참고 : 화면 방향 설정

스플래시 화면



iOS



iOS에서는 [Launch Image Source][Images.xcassets] 를 이용하도록 전환한 후 다음 설정을 합시다.

세로의 경우


옆의 경우


안드로이드



Android에서는 스플래시를 만들지 않는 것이 좋습니다.
아무래도 하는 분은 이 기사를 참고로 되어는 어떨까라고 생각합니다.
참고 : Android에서 스플래시 화면을 만드는 방법

후기



프로젝트 신규 작성시에는, 해상도 대응등 여러가지 일이 많이 있습니다.
어느 쪽은, 정리하려고 생각하고 있습니다만, 이번은 화면의 방향 설정에 대해였습니다.

참고 : cocos2dx 화면 해상도 대응

좋은 웹페이지 즐겨찾기