Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ResolutionPolicy

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

Hierarchy

  • ResolutionPolicy

Index

Constructors

constructor

Properties

Private _containerStrategy

_containerStrategy: null | ContainerStrategy

Private _contentStrategy

_contentStrategy: null | ContentStrategy

name

name: string = "ResolutionPolicy"

Static ContainerStrategy

ContainerStrategy: typeof ContainerStrategy = ContainerStrategy

Static ContentStrategy

ContentStrategy: typeof ContentStrategy = ContentStrategy

Static EXACT_FIT

EXACT_FIT: number = 0

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.

Static FIXED_HEIGHT

FIXED_HEIGHT: number = 3

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

Static FIXED_WIDTH

FIXED_WIDTH: number = 4

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

Static NO_BORDER

NO_BORDER: number = 1

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

Static SHOW_ALL

SHOW_ALL: number = 2

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.

Static UNKNOWN

UNKNOWN: number = 5

Unknown policy

Accessors

canvasSize

  • get canvasSize(): Vec2

Methods

apply

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

    Parameters

    • _view: View

      The target view

    • designedResolution: Size

      The user defined design resolution

    Returns AdaptResult

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

postApply

  • postApply(_view: View): void

preApply

  • preApply(_view: View): void

setContainerStrategy

setContentStrategy

Generated using TypeDoc