How to disable screen orientation change?

Hello,
this is my first post here and I am new to Cocos so hello everyone!
I am using IntelXDK and Cocos2d-JS. My target platforms are Android, iOS and Win, but I will be happy if it works only for Andr. and iOS.

  1. I want screen and full-screen canvas that cocos renders to, to be same dimensions in pixels.
  2. I would also like to disable orientation change when rotating device that causes applications graphics screen to change dimensions.

Thanks.

To disable orientation changes:

  • on iOS in xCode go to ProjectSettings -> General Tab, here you can find ‘Device orientation’ settings.
    Or you can directly modify Info.plist:
<key>UISupportedInterfaceOrientations</key>
<array>
	<string>UIInterfaceOrientationPortrait</string>
</array>
  • on android find AndroidManifest.xml and add/edit next properties for main activity (android:screenOrientation & android:configChanges)
<activity
            android:name="org.cocos2dx.cpp.AppActivity"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
1 Like