cocos2d-js android device orientation

465 views Asked by At

I have to ask: Anyone know how to create a simple Cocos2d-js project with the device orientation set to portrait?

I tried the following command:

    cocos new TestProject -l js --portrait

But, it sent me the following message:

    WARNING: Can't find step change_orientation.

When I tried to run the project on Android, the orientation was in landscape.

I want to create a game to android, and I already checked the orientation in AndroidManifest.xml and the orientation was "portrait". I tried to put, in the main.js, the resolution to "420,780", but it not worked too. I tried to create a project using cocos ide, setted the orientation to portrait, but it didn't compile to Android, and I couldn't figure out how they have setted the orientation to portrait. I tried to use the sample project, the js-moonwarrior, and I tried to figure out how they set the orientation, but I didn't find anything useful.

So.... Any of you know how to create a Cocos2d-js project in Portrait orientation?

Thank you in advance!

1

There are 1 answers

0
Alex G. G. On

You could create the project in the Cocos IDE but in the same window that the IDE aks you the orientation check add native codes with the name package you want. You will now have a project of android in PATH_TO_PROJECT/frameworks/runtime-src/proj.android

There you can change the orientation.

If you don't get to compile to compile to android, try to import the cocos2d-x sdk android[1] project in eclipse and your android project and add the cocos2d-x library to your android project.

[1] It is in cocos2d-x v.3.x/cocos/platform/android/java