您的位置:首页 > 移动开发 > Cocos引擎

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 :实际屏幕的大小。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: