Orientation Problems

Orientation Problems
0.0 0


I have been having multiple orientation issues. Looking for the best fix.

Simple Sample Code:

bool MyScene::init()
    if ( !CCLayer::init() )
        return false;

    screenSize = CCDirector::sharedDirector()->getWinSizeInPixels();

    sprite = cocos2d::CCSprite::spriteWithFile("target.png");
    sprite->setPosition (cocos2d::CCPoint(screenSize.width/2,screenSize.height/2));


    return true;

void MyScene::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event) {
    CCTouch* touch = (CCTouch*)( touches->anyObject() );
    CCPoint location = touch->locationInView(touch->view());
    location = CCDirector::sharedDirector()->convertToGL(location);


if app.icf is unmodified:
touch in portrait:android = good
touch in landLeft:android = y is offset (touch is always below y by ~200 pixels)
touch in landRight:android = y is offset (touch is always below y by ~200 pixels)
touch in portrait:iphone = good
touch in landLeft:iphone = touch is rotated 90 degrees to the left (if touch is at 0,0, then target will be at 320,0)
touch in landRight:iphone = confused, but i think its mapping to the same rect landLeft was. (if touch is 0,0, then target will be at 480-320,320)
touch in portraitInverse:iphone = touch is opposite of target (if touch is 50,50, then target will be at 320-50,480-50)
all coordinates are in perspective to the way I am holding the device

I can set app.icf
but it will still have the portraitInverse:iphone issue
(Application is supposed to at least be in portrait, landscape would be nice but I’m willing to settle)

Also, I have set deviceOrientation to kCCDeviceOrientationPortrait.

So here are my questions:
1a) Is there a way to detect orientation
1b) If not, is there a way to properly detect coordinates
1c) If not, is there a way to fully prevent all rotation
2) Any plans to integrate autorotation?
3) Any other fixes or suggestions?

I have been able to deal with orientation previously using Marmalade, so I know there is a solution, but I am unsure of how cocos2d connects to certain aspects of Marmalade, so I’m clueless as to where to begin.