quick-cocos2d 设置横屏

quick cocos2d新建项目,在xcode中 起模拟器,默认的是竖屏,我想做一个横屏的游戏,前面已经说了

 

选中你的项目,在General这个标签内,Deoployment info的这个分组,有一个Device Orientation 标签,内有一个Portrait的选项,选中是竖屏,取消选中是横屏

 

这里的横屏竖屏只是你显示的状态,而并非是你摆放游戏资源或者写代码按照坐标排布的横屏,这时候要设置Landscape Right,但是选中以后,就会直接崩溃

 

int main(int argc, char *argv[]) {

    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    int retVal = UIApplicationMain(argc, argv, nil, @"AppController");//会崩溃在这一句 

    [pool release];

    return retVal;

 

 

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [RootViewController shouldAutorotate] is returning YES'

libc++abi.dylib: terminating with uncaught exception of type NSException

这里的原因也已经讲清楚了,是你的初始化不支持横屏,我们需要做一个修改

 

在RootViewController.mm  中

 

// For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead

- (NSUInteger) supportedInterfaceOrientations

{

//加上这一句,然后试一下,一切 ok     

return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;

#ifdef __IPHONE_6_0

    return UIInterfaceOrientationMaskPortrait;

#endif

}

 

 

原文链接: https://www.cnblogs.com/fish124423/p/5893467.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    quick-cocos2d 设置横屏

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/240884

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午9:07
下一篇 2023年2月13日 下午9:08

相关推荐