cocos2dx 屏幕自适应
2016-04-21 16:01
441 查看
iphone4 / 4s 960*640 3:2
iphone5 1136*640 16:9
ipad 2 / mini 1024*768 4:3
newpad 2048*1536 4:3
三星Note2 1280*720 16:9
小米2 1280*720 16:9
三星s4 1920*1080 16:9
HTC One 1920*1080 16:9
sony L35h 1920*1080 16:9
由此可见,铺天盖地16:9 。就用16:9来设计,其他分辨率来适配。取1280*720为开发分辨率。
以下是涉及的函数。
/**
* Set the design resolution size.
* @param width Design resolution width.
* @param height Design resolution height.
* @param resolutionPolicy The resolution policy desired, you may choose:
* [1] kResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
* [2] kResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
* [3] kResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
*/
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
/** returns visible size of the OpenGL view in points.
* the value is equal to getWinSize if don't invoke
* CCEGLView::setDesignResolutionSize()
*/
CCSize getVisibleSize();
/** returns visible origin of the OpenGL view in points.
*/
CCPoint getVisibleOrigin();
/**
* Get the frame size of EGL view.
* In general, it returns the screen size since the EGL view is a fullscreen view.
*/
virtual const CCSize& getFrameSize() const;
一共四个函数,其实包含了4种数据。大小的单位均为像素。
design resolution size:后备缓冲区大小。
//////// Scale actor:纹理缩放系数,将图片放大的倍数。 2.1.4不要改变此值。系统会自动缩放。
visible size :如果后备缓冲区在屏幕上时间显示的大小。
visible origin :后备缓冲区与屏幕左下角 0,0 点重合的坐标。
frame size :实际屏幕的大小。
iphone5 1136*640 16:9
ipad 2 / mini 1024*768 4:3
newpad 2048*1536 4:3
三星Note2 1280*720 16:9
小米2 1280*720 16:9
三星s4 1920*1080 16:9
HTC One 1920*1080 16:9
sony L35h 1920*1080 16:9
由此可见,铺天盖地16:9 。就用16:9来设计,其他分辨率来适配。取1280*720为开发分辨率。
以下是涉及的函数。
/**
* Set the design resolution size.
* @param width Design resolution width.
* @param height Design resolution height.
* @param resolutionPolicy The resolution policy desired, you may choose:
* [1] kResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
* [2] kResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
* [3] kResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
*/
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
/** returns visible size of the OpenGL view in points.
* the value is equal to getWinSize if don't invoke
* CCEGLView::setDesignResolutionSize()
*/
CCSize getVisibleSize();
/** returns visible origin of the OpenGL view in points.
*/
CCPoint getVisibleOrigin();
/**
* Get the frame size of EGL view.
* In general, it returns the screen size since the EGL view is a fullscreen view.
*/
virtual const CCSize& getFrameSize() const;
一共四个函数,其实包含了4种数据。大小的单位均为像素。
design resolution size:后备缓冲区大小。
//////// Scale actor:纹理缩放系数,将图片放大的倍数。 2.1.4不要改变此值。系统会自动缩放。
visible size :如果后备缓冲区在屏幕上时间显示的大小。
visible origin :后备缓冲区与屏幕左下角 0,0 点重合的坐标。
frame size :实际屏幕的大小。
相关文章推荐
- Visual Studio:error MSB8020
- cocos2dx 图片模糊
- 讨论:如何降低Cocos2d开发的游戏包体大小
- cocos2d-x 3.2 项目创建、控制台编译apk
- 讨论:如何降低Cocos2d开发的游戏包体大小
- cocos2d-x如何优化内存的应用
- Cocos2D 触摸分发原理
- Android游戏开发cocos2d-x调用Java层代码
- VS2010-win32下cocos2dx控制台打印的方法
- 关于emjoy表情在android5.x以上系统触发jni错误的修改(基于cocos2dx2.1.5修改)
- cocos2dx多线程以及线程同步 与 cocos2dx内存管理与多线程问题
- cocos2d-x屏幕适配原理分析
- cocos2dx多线程以及线程同步 与 cocos2dx内存管理与多线程问题
- Cocos2dx 3.0 交流篇
- cocos2d-x 3.1 集成 云风pbc
- COCOS2DX 3.0 优化提升渲染速度 Auto-batching
- COCOS2DX WIN32 版本的CPU占用25%改良策略
- cocos2dx libevent简介和使用
- Quick-cocos2d-x 与COCOS2DX 区别
- 比较Cocos2d-x v2.x与v3.x的截图功能