zoukankan      html  css  js  c++  java
  • Cocos2dx 设置竖屏的方法 2.0以上版本

    在网上搜了千百遍终于终于找到对的方法了。。

    在网上搜的大部分结果是把(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation();函数中的语句改成如注释掉的:

     

    (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

        returnUIInterfaceOrientationIsLandscape( interfaceOrientation );

    //    return (UIInterfaceOrientationIsPortrait( interfaceOrientation ));

    }

     

    可是在本人机子上做实验就是不成功。。。我的cocos2d的版本是2.1beta3-x-2.1.1

     

    最终正确的方法如下:不是修改上面的函数而是把(NSUInteger) supportedInterfaceOrientations();函数中的语句改成注释掉的

    - (NSUInteger) supportedInterfaceOrientations{

    #ifdef __IPHONE_6_0

        returnUIInterfaceOrientationMaskLandscape;

    //     return UIInterfaceOrientationMaskPortrait;

    #endif

    }

    这样实验就成功了。。。

    两函数所在目录:Cocos2d-x项目目录iOS目录中的RootViewController.mm文件中。。。

     

    如果你试验还是不成功试着把RootViewController.mm文件中的如下3个函数全部改成注释掉的部分:

    函数一:

    (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

        return UIInterfaceOrientationIsLandscape( interfaceOrientation );

    //    return (UIInterfaceOrientationIsPortrait( interfaceOrientation ));

    }

    函数二:

    - (NSUInteger) supportedInterfaceOrientations{

    #ifdef __IPHONE_6_0

        return UIInterfaceOrientationMaskLandscape;

    //     return UIInterfaceOrientationMaskPortrait;

    //    直式显示: protrait

    //    横式显示: landscape

    #endif

    }


    函数三:

    - (BOOL) shouldAutorotate {

        returnYES;

    //    return NO;

    }

  • 相关阅读:
    mybatis框架查询用户表中的记录数
    文件的上传和下载
    怎样在一条sql语句中将第一列和第二列加和的值作为第三列的值
    [OS] 进程的虚地址空间
    [网络] TCP/IP协议族各层的协议汇总
    [面试] C++ 虚函数表解析
    [OS] 堆栈、堆、数据段、代码段
    [算法] 并查集概念及其实现
    [OS] 我与大牛的对话!
    [C] int *p[4]与int (*q)[4]的区别
  • 原文地址:https://www.cnblogs.com/GameDeveloper/p/3026414.html
Copyright © 2011-2022 走看看