CCDirector::getWinSize() returns coordinates backwards in this instance

Hi there, having a slight issue with the CCDirector::getWinSize() function.

My project is
* an iPhone project (Xcode)
* that runs in landscape set via project settings (not using CCDirector::setDeviceOrientation — cocos2d still thinks it’s in portrait)
* and this only happens at the very start of the project in response to AppDelegate::applicationDidFinishLaunching.

If I call getWinSize inside applicationDidFinishLaunching, it reports 320 x 480.

If I call it a few frames later, it correctly reports 480 x 320.

Any ideas?

In CCDirector.cpp:
bool CCDirector::init(void)
{

// portrait mode default
m_eDeviceOrientation = CCDeviceOrientationPortrait;

}

CCSize CCDirector::getWinSize(void)
{
CCSize s = m_obWinSizeInPoints;

if (m_eDeviceOrientation CCDeviceOrientationLandscapeLeft
|| m_eDeviceOrientation CCDeviceOrientationLandscapeRight)
{
// swap x,y in landspace mode
CCSize tmp = s;
s.width = tmp.height;
s.height = tmp.width;
}

return s;
}

So if you didn’t use CCDirector::setDeviceOrientation in applicationDidFinishLaunching, getWinSize returned portrait size.Maybe a few later, m_eDeviceOrientation will be setted landscape.

No, m_eDeviceOrientation never gets set to landscape. However the app will report 480 x 320 if you wait a second, but m_eDeviceOrientation never changes from portrait.

If you set it to landscape, the game goes upside-down portrait.

Okay, I’m struggling to understand this, but landscape-right works fine, whereas landscape-left goes portrait.

I have the same problem. The device orientation has major flaws in Cocos2d-x on iOS.

http://www.cocos2d-x.org/boards/7/topics/9437