Search code examples
iphoneioscocos2d-iphonecocos2d-x

set cocos2-x project to portrait orientation


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:

At RootViewController.mm:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskPortrait;
#endif
}

I also tried changing the settings, still nothig.

setDeviceOrientation does not exist anymore...

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

UPDATE: It seems to work on the device, it only happens on the simulator


Solution

  • I do it this way: In xcode at the top of the file list is the project. Go to that, then the "Targets > whatever" bit. You have "supported Interface orientations". You can check off which orientations you want and don't want. Make sure to note that there are 2 different sections for iPhone and iPad, you'll have to scroll down and set it separately in the iPad orientation section.

    I'd imagine the reason it doesn't work in the simulator is that you're using an iPhone/iPod for testing and running the iPad simulator.