Screen orientation issues (resolved)

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.
Jon
@
daySky = CCSprite::spriteWithFile(”media/scene_sky1.png“);
CC_BREAK_IF(!daySky);
tree = CCSprite::spriteWithFile(”media/scene_tree.png“);
CC_BREAK_IF(!tree);
ground = CCSprite::spriteWithFile(”media/scene_ground.png");
CC_BREAK_IF(!ground);
CCSize size = CCDirector::sharedDirector()
>getWinSize;
daySky~~>setPosition(ccp(size.width/2, size.height/2));
tree~~>setPosition.width/2, size.height-tree~~>getContentSizeInPixels().height/2-5));
ground~~>setPosition);
this~~>addChild(daySky, 0);
this~~>addChild;
this~~>addChild(ground, 0);
@

@
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector pDirector = CCDirector::sharedDirector;
pDirector~~>setOpenGLView);
// sets landscape mode
pDirector~~>setDeviceOrientation;
// turn on display FPS
pDirector~~>setDisplayFPS;
// set FPS. the default value is 1.0/60 if you don’t call this
pDirector~~>setAnimationInterval;
// create a scene. it’s an autorelease object
CCScene
pScene = PuppyComeHome::scene();
// run
pDirector->runWithScene(pScene);
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.
~~Jon