quick-cocos2d-x 如何设置游戏的屏幕方向
2014-02-25 21:21
597 查看
如何设置游戏的屏幕方向
2013/08/08quick-cocos2d-xxcodeYuLei Liao
quick 中的 create_project 工具在创建项目时,可以用 -o 参数指定屏幕方向。但如果要修改已有项目的屏幕方向,就要按如下步骤进行。
对于 iOS 项目
设置工程可用的屏幕方向:![](http://cn.quick-x.com/wp-content/uploads/2013/08/xcode_project_screen_-orientation_01.png)
找到 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 }
如果需要竖屏:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsPortrait(interfaceOrientation); } // For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations { #ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskPortrait; #endif }
按照 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"
如果需要竖屏:
-- design resolution CONFIG_SCREEN_WIDTH = 640 CONFIG_SCREEN_HEIGHT = 960 CONFIG_SCREEN_ORIENTATION = "portrait" -- auto scale mode CONFIG_SCREEN_AUTOSCALE = "FIXED_WIDTH"
- END -
文章导航
← quick-x-player 使用说明导出C/C++ API 给 Lua 使用 →
《如何设置游戏的屏幕方向》有2个想法
相关文章推荐
- 【cocos2d-x入门实战】微信飞机大战之十五:跨平台移植和广告植入
- cocos2d-x 创建项目
- bombing:cocos2d-x之CCDirector类2
- cocos2d-x之CCDirector类1
- cocos2d-x应用窗口相关源码剖析5-其他细节
- cocos2d-x 骨骼动画详解
- cocos2d-x应用窗口相关源码剖析4
- bombing:cocos2d-x应用窗口相关源码剖析3
- cocos2d-x应用窗口相关源码剖析2
- cocos2d-x应用窗口相关源码剖析1
- cocos2dx 文件处理
- cocos2d-x 血泪史(-3) winrt 的环境配置单
- cocos2d中的光照效果
- quick-cocos2d-x API 以及 参考手册
- 在quick-cocos2d-x中创建新工程
- COCOSBuilder 源码, cocos2d 和cocos2dx混编
- 设置 quick-cocos2d-x 在 Mac 下的编译环境
- cocos2d-x 常见的几种特效
- Mac下搭建quick cocos2d-x编译环境
- 如何学习 quick-cocos2d-x