将游戏从肖像模式转换为风景模式

将游戏从肖像模式转换为风景模式

问题描述:

我是cocos2d新游戏开发。在这里,我的游戏是以肖像模式开发的。我只想转换横向模式。并告诉我使用哪种方法而不是shouldAutorotateToInterfaceOrientation方法,因为此方法在iOS 6中不可用?将游戏从肖像模式转换为风景模式

我的整个游戏都是从一开始就开发人像模式。

预先感谢您。

+0

你的意思是在风景还是风景? – rptwsthi

+0

其中cocos2d版本是你工作的1.x或2.x? – IronMan

不知道这会解决您的问题,但正如你所提到如何处理OS6方向,我想给你的代码,我使用的是什么在iOS 6中和110 5等处理设备的方向

因此,这里的代码剪断,在那里你可以决定你想要什么方位支持你的应用程序

手柄屏幕方向中的iOS 5和iOS 6

//For up-to iOS 5.0 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported all orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 


//For iOS 6.0 
-(NSInteger)supportedInterfaceOrientations 
{ 
    //Supporting only portrait orientation. 
    return UIInterfaceOrientationMaskPortrait; 
} 

-(BOOL)shouldAutorotate 
{ 
    return NO; 
} 

Reference

希望这会帮助你!

转到目标并设置支持的界面方向。

,你会发现下面的代码appdelegate.mm文件

#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
[director setDeviceOrientation:kCCDeviceOrientationPortrait]; 
#else 
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 

改变它。

#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 
#else 
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 

让我知道它工作与否!