Cocos Creator API

1.0.0

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

ResolutionPolicy

Module: 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

Methods

ResolutionPolicy
(
  • containerStg
  • contentStg
)

name type description
containerStg ContainerStrategy

The container strategy

contentStg ContentStrategy

The content strategy

preApply
(
  • view
)

Manipulation before applying the resolution policy

name type description
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

name type description
view View

The target view

designedResolution Size

The user defined design resolution

returns:

type: Object

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

postApply
(
  • view
)

Manipulation after appyling the strategy

name type description
view View

The target view

setContainerStrategy
(
  • containerStg
)

Setup the container's scale strategy

name type description
containerStg ContainerStrategy

setContentStrategy
(
  • contentStg
)

Setup the content's scale strategy

name type description
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