Portrait orientation

Portrait orientation
0.0 0


Hi all,

I am trying to set up my project with portrait orientation, but I am just getting landscape. I am using cocos2d-x (2.1.4).

I have set, as said here: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Device_Orientation

At RootViewController.mm:

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsPortrait( interfaceOrientation );
    // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
  • (NSUInteger) supportedInterfaceOrientations{
    #ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskPortrait;

I also tried changing the settings, still nothig.

setDeviceOrientation does not exist anymore…

Anyone knows how I can set the project to portrait??


You have to set orientation in the project. Go to Targets, select your target Summary and set Supported orientations.
After that actions, in RootViewController.mm you should write such code:

~~supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
~~(BOOL)shouldAutorotate {
return [[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait;

That should works.