cocos2d-x 3.2 以及2.2.3 Director类分析
来源:互联网 发布:关键规则算法 编辑:程序博客网 时间:2024/06/05 15:19
// In this demo, we select resource according to the frame's height. // If the resource size is different from design resolution size, you need to set contentScaleFactor. // We use the ratio of resource's height to the height of design resolution, // this can make sure that the resource's height could fit for the height of design resolution. // if the frame's height is larger than the height of medium resource size, select large resource.
<span style="white-space:pre"></span>/*
<span style="white-space:pre"></span>首先资源又很多个版本1920*11080 到 960*640 一堆分辨率,这处没有处理16:9或者16:10的差异性,我们可以增加资源切边或直接拉伸挤压,影响不大,至少看起来能跑。当屏幕或者帧大于最高清资源的高度时,直接选择最高清。
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"></span>*/</span>if (frameSize.height > mediumResource.size.height){ searchPath.push_back(largeResource.directory); pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));} // if the frame's height is larger than the height of small resource size, select medium resource.
<pre name="code" class="cpp"><span style="white-space:pre"></span>/*
<span></span>当屏幕或者帧小于最高清资源的高度且大于最小资源的设置,则选择<span style="font-family: Arial, Helvetica, sans-serif;">mediumResource,这个目录值得纠结一下,暂时没完成过完整的屏幕适配。</span>。
<span style="font-family: Arial, Helvetica, sans-serif;"><span></span>*/</span>else if (frameSize.height > smallResource.size.height) { searchPath.push_back(mediumResource.directory); pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width)); }
<pre name="code" class="cpp"><pre name="code" class="cpp"><span style="white-space:pre"></span>/*
<span></span>当屏幕或者帧小于最劣质资源的高度设置,则选择<span style="font-family: Arial, Helvetica, sans-serif;">smallResource</span><span style="font-family: Arial, Helvetica, sans-serif;">,这个目录值得纠结一下,暂时没完成过完整的屏幕适配。</span>。
<span style="font-family: Arial, Helvetica, sans-serif;"><span></span>*/</span>// if the frame's height is smaller than the height of medium resource size, select small resource.else { searchPath.push_back(smallResource.directory); pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width)); } // set searching path CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
也就是说,我们设置好资源的路径值和searchPath就可以解决之前遇到的屏幕适配问题。对于16:9和16:10的问题,我只能说iPhone都是16:9了,但是我们还是要去做切边的设置。都要了解切边具体操作。后续补。
0 0
- cocos2d-x 3.2 以及2.2.3 Director类分析
- cocos2d-x源码分析之Director::drawScene()
- 读书笔记Cocos2d-x之Director
- cocos2d-X 导演类(Director.h)API
- Cocos2d-x学习笔记《06》—— 导演类Director
- Cocos2d-X3.0 刨根问底(三)----- Director类源码分析
- cocos2d-x Director Scene Layer and Sprite
- Cocos2d-x 3.0-Director和场景跳转
- cocos2d-x 入门之Director,SceneLayer,Sprite
- cocos2d-iphone源码分析(2):Director
- Cocos2d-x v3.1 核心类Director,Scene,Layer和Sprite(六)
- Cocos2D-X学习4:几个重要的类:Node、Director、Scene、Layer
- cocos2d-x 2.2.3 CCDictionary类简单分析
- cocos2d-x 2.2.3环境问题分析
- cocos2d-x 2.2.3 ccArray简单分析
- cocos2d-x 2.2.3 CCKeypadDispatcher简单分析
- CCObject的分析:release、retain 基于2.2.3,增加3.2 ref对比,Director游戏主线分析
- cocos2d-x-2.2中编译cocos2d-win32.vc2010 C1083 pthread.h No such file or director错误的解决办法
- 内存链
- 贝叶斯神经网络工具包FullBNT,在Matlab中的导入及应用实例
- 初谈二进制和编码
- CentOS 默认python的版本更换
- 华人操作系统列表
- cocos2d-x 3.2 以及2.2.3 Director类分析
- appstore应用被拒绝显示Prepare for Submission
- SpringMVC的第一个入门案例
- Learn C# scripting in Unity
- notepad++比较不错的技巧
- HDU 4419 Colourful Rectangle (线段树扫描线)
- 8连块
- AFNetworking2的SSL身份认证 -1022错误解决办法
- 设计模式-单例模式