Screen orientation issues (resolved)

Screen orientation issues (resolved)
0.0 0


Hi. I’m a first time poster with a starter issue. I’ve almost got the Android-NDK-port all straightened out except for this: the orientation is always either landscape or upside down. This issue is present both for the emulator and physical device. Here are some details.
Calls to “CCDirectory~~>setDeviceOrientation" have limited effect in the win32 version but this parameter seems to have no effect in the NDK-port.
Changes to the “android:orientation” in the NDK-port’s application manifest, however, show up as upside-down portrait for “landscape” and sideways for “portrait”.
I’ve included 2 pictures to illustrate what I mean and below is some of the code that is used in my project. If you need anything else, just ask.
I’m sure this is a silly misstep on my part, but I can’t seem to resolve it. I started with the “hello world” app as a template to build from, which might have something to do with my problems. I’d done a good amount of searching before starting this post, and couldn’t see any references to the issue or a resolution.
Thanks for any help you can provide.
daySky = CCSprite::spriteWithFile(”media/scene_sky1.png“);
tree = CCSprite::spriteWithFile(”media/scene_tree.png“);
ground = CCSprite::spriteWithFile(”media/scene_ground.png");
CCSize size = CCDirector::sharedDirector()
daySky~~>setPosition(ccp(size.width/2, size.height/2));
tree~~>setPosition.width/2, size.height-tree~~>getContentSizeInPixels().height/2-5));
this~~>addChild(daySky, 0);
this~~>addChild(ground, 0);

bool AppDelegate::applicationDidFinishLaunching()
// initialize director
CCDirector pDirector = CCDirector::sharedDirector;
// sets landscape mode
// turn on display FPS
// set FPS. the default value is 1.0/60 if you don’t call this
// create a scene. it’s an autorelease object
pScene = PuppyComeHome::scene();
// run
return true;


<?xml version="1.0" encoding="utf-8"?>


android1.png (177.8 KB)

android2.png (206.5 KB)


There are two ways to set the orientation.

  1. Set the orientation in manifest
    This method tell the Android system to set the orientation. It is the real orientation of the view. I mean, any other Android widget will have the orientation setted in manifest.

  2. Set by pDirector->setDeviceOrientation()
    The engine changes the orientation by changing the coordinate system used in engine, the real orientation is setted in manifest.


Hi Minggo, thanks for the quick reply.
Haha! I found the issue. The problem was that when I’d imported my android project into eclipse, I’d neglected to turn off the “Copy projects into workspace” check-box. This meant that my android project was copied once when first imported and any changes made to the “pDirector~~>DeviceOrientation” were not being sent to the eclipse copy.
Everything seems to be working now. Case closed.