首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将游戏从纵向模式转换为横向模式

将游戏从纵向模式转换为横向模式
EN

Stack Overflow用户
提问于 2013-05-22 13:51:12
回答 3查看 448关注 0票数 1

我是cocos2d游戏开发的新手。在这里,我的游戏是在纵向模式下开发的。我只是想转换一下横向模式。并告诉我使用哪种方法来代替shouldAutorotateToInterfaceOrientation方法,因为iOS 6中不提供此方法?

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

提前谢谢你。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-05-22 14:31:08

我不确定这会不会解决你的问题,但正如你提到的如何在OS6中处理方向,我想给你我在iOS 6和iO5等中用来处理设备方向的代码。

下面是代码片段,您可以在其中决定要在应用程序中使用的方向支持

处理iOS 5和iOS 6中的屏幕方向

代码语言:javascript
复制
//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

希望这能对你有所帮助!

票数 1
EN

Stack Overflow用户

发布于 2013-05-22 14:13:20

您将在appdelegate.mm文件中找到以下代码

代码语言:javascript
复制
 #if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
 #else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];

将其更改为。

代码语言:javascript
复制
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
 #else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];

让我知道它是否正常工作!

票数 3
EN

Stack Overflow用户

发布于 2013-05-22 13:53:17

转到目标并设置支持的接口方向。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16684377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档