Phaser API Documentation

  Version: 

Member of: Phaser.Structs.Size

setAspectMode([value])

Description:

Sets the aspect mode of this Size component.

The aspect mode controls what happens when you modify the width or height properties, or call setSize.

It can be a number from 0 to 4, or a Size constant:

  1. NONE = Do not make the size fit the aspect ratio. Change the ratio when the size changes.
  2. WIDTH_CONTROLS_HEIGHT = The height is automatically adjusted based on the width.
  3. HEIGHT_CONTROLS_WIDTH = The width is automatically adjusted based on the height.
  4. FIT = The width and height are automatically adjusted to fit inside the given target area, while keeping the aspect ratio. Depending on the aspect ratio there may be some space inside the area which is not covered.
  5. ENVELOP = The width and height are automatically adjusted to make the size cover the entire target area while keeping the aspect ratio. This may extend further out than the target size.

Calling this method automatically recalculates the width and the height, if required.

Parameters:

name type arguments description
value number <optional>

The aspect mode value.

Returns:
Description:

This Size component instance.

Since: 3.16.0
Source: src/structs/Size.js (Line 156)