cocos2d-js: How to set viewport orientation (landscape / portrait)?
-
21-12-2019 - |
Question
How can I set the viewport orientation in cocos2d-js 3.0?
I found the variables
cc.UIInterfaceOrientationPortrait
cc.UIInterfaceOrientationLandscapeLeft
cc.UIInterfaceOrientationLandscapeRight
cc.UIInterfaceOrientationPortraitUpsideDown
in CCInputManager.js but no function to actually set them.
And I found this description:
http://www.cocos2d-x.org/wiki/Device_Orientation
but it is different for Android and iOS and that contradicts the cocos run command.
Solution
In Android just edit the file
frameworks/runtime-src/proj.android/AndroidManifest.xml
in the project directory. Change
android:screenOrientation="landscape"
to
android:screenOrientation="portrait"
OTHER TIPS
you can change in your project config.json
{
"init_cfg":{
"isLandscape": false,
"isPotrait":true,
"isWindowTop": false,
"name": "untitled",
"width": 960,
"height": 640,
"entry": "main.js",
"consolePort": 6050,
"uploadPort": 6060,
"debugPort": 5086
},
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow