Cocos2d view mode does not work on iPhone

I am creating a cocos2d game which should be in portrait mode. I changed the mode of RootViewController.m in portrait mode, and everything works fine, both on the simulator and on my iPad. However, when I launch the game on my iPhone, it defaults to landscape mode.

Any ideas on how to fix this?

Thank.

+5
source share
5 answers

I have a better solution that will work 100%:

Replace everything that was in RootViewController.m / shouldAutorotateToInterfaceOrientation Method with the following:

return (UIInterfaceOrientationIsPortrait (interfaceOrientation));

- /:

[[CCDirector sharedDirector] setDeviceOrientation: CCDeviceOrientationLandscapeLeft];

,

+7

GameConfig.h:

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationCCDirector 

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController

AppDelegate.m

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
...
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
+1

Internally, the RootViewController returns false from the method below:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return false; 

   // other code...

}
0
source

In RootViewController.m

return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );

change this line to

return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );
0
source

in GameConfig.h:

For 1st and 2nd generation devices, value is set to kGameAutorotationNone, change it to kGameAutorotationUIViewController.

// ARMv6 (1st and 2nd generation devices): Don't rotate. It is very expensive
#elif __arm__
#define GAME_AUTOROTATION kGameAutorotationNone
0
source