Autorotation problem

Autorotation problem
0.0 0


Hello guys,

I’m facing some orientation problems in my Android Cocos2d-x app. I’ve seen tons of people talking about autorotation in iOS but not that much in Android.

When I rotate my device 180 degrees my opengl screen does not rotate. Is there something that I should do specifically in order to support this?

I really need that the opelgl view also rotate while the device gets rotated.

OBS: My Cocos2d-x version is 2.0.4.

Thanks in advance.



I am facing the same problem.
Thanks for any help.



Nico L. wrote:

I am facing the same problem.
Thanks for any help.

Hi Nico!

My problem was not in Cocos2d-x. In fact, my problem was in the android application. By default cocos2d-x android application is set only to landscape orientation and thats is the problem. You don’t need to get the orientation events, nothing like that, you just need to change the screen orientation parameter in your android manifest file.

By default you have: android:screenOrientation=“landscape”. This causes the problem! It does not rotate no matter what you do! To change this behavior you have to change to android:screenOrientation=“sensorLandscape” in case you application supports only landscape orientation. This way it will work in both in landscape and reverseLandscape.

Is your application only landscape? Or it supports landscape and portrait orientations?

You don’t need to override the method onConfigurationChanged, unless you want both orientations to work.

Hope it helps.


Hi Guilherme,
thanks for your reply.

My application effectively only in landscape.

But I dont have the value “sensorLandscape” in my ManifestFile.
I have the following ones : unspecified, landscape, portrait, user, behind, sensor, nosensor.

If I put sensor, the application start in portrait mode, and after the rotation in landscape, I have half the screen black.

How do you get the “sensorLandscape” value ?


I got it
sorry I should have googled it before.
I needed to use at least API 9.
Now it works.




Build against 8 and add this to your onCreate()