Cocos2d-x   发布时间:2022-05-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了quick-cocos2d-x 如何设置游戏的屏幕方向大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

quick 中的 create_project 工具在创建项目时,可以用 -o 参数指定屏幕方向。但如果要修改已有项目的屏幕方向,就要按如下步骤进行。

对于 iOS 项目

  1. 设置工程可用的屏幕方向:

  2. 找到 RootViewController.mm 文件,做如下修改:

    如果需要横屏:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    
    // For ios6.0 and higher,use supportedInterfaceOrientations & shouldAutorotate instead
    - (NSUInteger) supportedInterfaceOrientations
    {
    #ifdef __IPHONE_6_0
        return UIInterfaceOrientationMaskLandscape;
    #endif
    }

    如果需要竖屏:

    - (UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsPorTrait(interfaceOrientation);
    }
    
    #ifdef __IPHONE_6_0
        return UIInterfaceOrientationMaskPorTrait;
    #endif
    }
  3. 按照 Apple 文档要求,制作不同屏幕方向需要的启动画面文件 (Default.png)。文档地址:iOS Human Interface Guidelines – Launch Images

对于 Android 项目

修改 AndroidManifest.xml 文件中的 android:screenOrientation 属性:

  • landscape 横屏
  • porTrait 竖屏

修改 config.lua 配置

如果需要横屏:

-- design resolution
CONFIG_SCREEN_WIDTH  = 960
CONFIG_SCREEN_HEIGHT = 640
CONFIG_SCREEN_ORIENTATION = "landscape"

-- auto scale mode
CONFIG_SCREEN_AUTOSCALE = "FIXED_HEIGHT"

如果需要竖屏:

640
CONFIG_SCREEN_HEIGHT = 960
CONFIG_SCREEN_ORIENTATION = "porTrait"

"FIXED_WIDTH"

大佬总结

以上是大佬教程为你收集整理的quick-cocos2d-x 如何设置游戏的屏幕方向全部内容,希望文章能够帮你解决quick-cocos2d-x 如何设置游戏的屏幕方向所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。