Cocos2d肖像模式不适用于iPhone
我正在构build一个应该是肖像模式的cocos2d游戏。 我将RootViewController.m更改为纵向模式,并且在模拟器和iPad上都可以正常工作。 但是,当我在iPhone上运行游戏时,它默认回到横向模式。
有想法该怎么解决这个吗?
谢谢。
我有一个更好的解决scheme,将工作100%:
将RootViewController.m / shouldAutorotateToInterfaceOrientation方法中的所有内容replace为以下内容:
返回(UIInterfaceOrientationIsPortrait(interfaceOrientation));
如果我想在运行时/切换场景中更改方向:
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeLeft];
请注意,Auto Rotation现在已经被支持
在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];
在RootViewController里面从下面的方法返回false:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return false; // other code... }
在RootViewController.m中
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
改变这一行
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );
在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