Cocos Creator API

1.2.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

ResolutionPolicy

模块: cc

cc.ResolutionPolicy class is the root strategy class of scale strategy, its main task is to maintain the compatibility with Cocos2d-x

属性(properties)

EXACT_FIT Number readOnly static

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.

NO_BORDER Number readOnly static

The entire application fills the specified area, without distortion but possibly with some cropping,
while maintaining the original aspect ratio of the application.

SHOW_ALL Number readOnly static

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.

FIXED_HEIGHT Number readOnly static

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

FIXED_WIDTH Number readOnly static

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

UNKNOWN Number readOnly static

Unknow policy

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

方法

ResolutionPolicy
(
  • containerStg
  • contentStg
)

名称 类型 描述
containerStg ContainerStrategy

The container strategy

contentStg ContentStrategy

The content strategy

preApply
(
  • view
)

Manipulation before applying the resolution policy

名称 类型 描述
view View

The target view

apply
(
  • view
  • designedResolution
)
Object

Function to apply this resolution policy The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, The target view can then apply these value to itself, it's preferred not to modify directly its private variables

名称 类型 描述
view View

The target view

designedResolution Size

The user defined design resolution

返回:

类型: Object

An object contains the scale X/Y values and the viewport rect

postApply
(
  • view
)

Manipulation after appyling the strategy

名称 类型 描述
view View

The target view

setContainerStrategy
(
  • containerStg
)

Setup the container's scale strategy

名称 类型 描述
containerStg ContainerStrategy

setContentStrategy
(
  • contentStg
)

Setup the content's scale strategy

名称 类型 描述
contentStg ContentStrategy

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index