I'm building a cocos2d game which is supposed to be in portrait mode. I changed the RootViewController.m to portrait mode, and everything works fine, both on the simulator and on my iPad. However, when I run the game on my iPhone, it defaults back to landscape mode.
Any ideas on how to fix this?
Thanks.
I have a better solution that will work 100%:
Replace all the stuff that was in the RootViewController.m / shouldAutorotateToInterfaceOrientation Method with following:
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );
And if I ever want to change the orientation during runtime / switching scene:
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeLeft];
Note that Auto Rotation is now on longer supported
in GameConfig.h:
use the director for autorotation
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationCCDirector
instead of
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController
and in the AppDelegate.m
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
...
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With