I put my profile in landscape:
<activity
android:name="org.cocos2dx.cpp.AppActivity"
android:screenOrientation="landscape"
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>
Then I start my game and print the origin and the visible size.
log("DEBUG: origin = %f, %f", origin.x, origin.y);
log("DEBUG: visibleSize = %f, %f", visibleSize.width, visibleSize.height);
The output was: (BTW, the design resolution was 1024 x 768)
D/cocos2d-x debug info: DEBUG: origin = 0.000000, 75.772583
D/cocos2d-x debug info: DEBUG: visibleSize = 1024.000000, 616.454834
Notice that the "back-home-apps" system bar is on the right side of the screen. I also tried to put the image to the middle of the screen by setting it's position to be (origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2)
, but as you can see, because of the wrong visible size and origin, the image is towards the lower part of the screen.
I was expecting that the origin should be (0,0) and the visible size should be (1024 - height-of-system-bar
) x 768. But as you can see the origin has a delta on Y
axis, and the visible size take a hit also on Y
axis --- as if Cocos2d-x thought that the screen was in portrait orientation and the system bar is at the bottom of the screen.
How do I tell cocos2d that the phone is in landscape orientation?