How to change device oritation for Windows with cocos2d-x 2.0

Hi,

I am porting a cocos2d-x project from ios to Windows, but I don’t know how to change device oritation on Windows.

On ios, I saw I can change it in ios\RootViewController.mm. But on windows, is there a way to change device simulator’s orientation either?

thanks,

HouZhe

are you talking about windows phone? This might help: http://www.robmiles.com/journal/2010/8/15/understanding-windows-phone-orientation-in-xna.html

But there is a specific forum for windows I guess.

Hello, J B,

thanks for your reply. But I think you are talking about Windows Phone development using c#? In fact, I just try to debug something using cocos2d-x C++ framework on Windows. And I found there is no interface to change device’s orientation on Simulator. by checking codes, I found this comments about class CCDirector:

The CCDirector is also responsible for:

  • initializing the OpenGL context

  • setting the OpenGL pixel format (default on is RGB565)

  • setting the OpenGL buffer depth (default one is 0-bit)

  • setting the projection (default one is 3D)

  • setting the orientation (default one is Protrait)

But by checking its declaration, seems no interface to change orientation. Only one member looks like defined for that purpose:

/* landscape mode ? */

bool m_bLandscape;

but this member is never used anywhere. So is this function is missed somehow? I am using cocos2d-x 2.0. thanks.

I can’t find this function too.
In cocos2d-x ver 13 was:
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);

Current, I am aware that the function to set device orientation is platform dependent. on windows, it is done in the program’s main function generated by template:

eglView.setFrameSize(320, 480);

// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// eglView.setDesignResolutionSize(480, 320);

On iOS, it is done by the function I mentioned in the above message. On Adroid, I have not checked it.

I forced eglView to a portrait resolution like you did above (320,480), but my input and the window width/height returned incorrect values. Were you able to fix these issues?

What OS are you working on? I resolved the problem on iOS and Win-mobile. And I just tried cocos2d-x2.0, not sure whether the concerned logic is changed in higher version.