cocos2d-x的 setFrameZoomFactor 和 多分辨率策略

 

1、setFrameZoomFactor : 调用这个函数,可以直接把程序窗口缩放
 

     setFrameZoomFactor 调用这个函数是因为有的移动设备屏幕分辨率非常大,

比如ipad3。太大的话在电脑上看不全了,所以用setFrameZoomFactor把程序窗口缩小

所以,这个函数只能用win32,mac,linux桌面时才用到

    2、DesignResolutionSize:游戏分辨率方案,一般根据图片资源尺寸,自适配分辨率缩放因子

    这个DesignResolutionSize表示设计方案,就是你的游戏完美支持的分辨率方案

,一般根据图片资源的尺寸来定,自适配时会按照这个分辨率计算出缩放因子。

因此,这个值也应该是动态的

  

3、DesignResolutionSize  三种适配策略:游戏分辨率方案,一般根据图片资源尺寸,自适配分辨率缩放因子
 

3. pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

第3个参数kResolutionNoBorder 是适配策略中的一种:

2.0版本提供了三种适配策略:

(1)kResolutionNoBorder:超出屏幕的部分会被裁剪,两侧没有黑边,铺满屏幕,按图片原始比例显示,图片不变形。

(2)kResolutionShowAll:整个游戏界面是可见的,会按原始比例进行缩放,图片不变形,但两侧可能会留有黑边,不铺满屏幕。

(3)kResolutionExactFit:整个游戏界面是可见的,图片可能会进行拉伸或者压缩处理,铺满屏幕,图片会变形。

可以根据自己的要求选择。

   cocos2dx 2.1.14版本 解决适配策略解决方案枚举

#ifndef __CCEGLVIEWPROTOCOL_H__
#define __CCEGLVIEWPROTOCOL_H__

#include "ccTypes.h"

enum ResolutionPolicy
{
    // The entire application is visible in the specified area without trying to preserve the original aspect ratio.
    // Distortion can occur, and the application may appear stretched or compressed.
    kResolutionExactFit,
    // The entire application fills the specified area, without distortion but possibly with some cropping,
    // while maintaining the original aspect ratio of the application.
    kResolutionNoBorder,
    // The entire application is visible in the specified area without distortion while maintaining the original
    // aspect ratio of the application. Borders can appear on two sides of the application.
    kResolutionShowAll,
    // The application takes the height of the design resolution size and modifies the width of the internal
    // canvas so that it fits the aspect ratio of the device
    // no distortion will occur however you must make sure your application works on different
    // aspect ratios
    kResolutionFixedHeight,
    // The application takes the width of the design resolution size and modifies the height of the internal
    // canvas so that it fits the aspect ratio of the device
    // no distortion will occur however you must make sure your application works on different
    // aspect ratios
    kResolutionFixedWidth,

    kResolutionUnKnown,
};

NS_CC_BEGIN

#define CC_MAX_TOUCHES  5

猜你喜欢

转载自andinker.iteye.com/blog/1967586
今日推荐