Namespace: ComputedSize

Phaser.GameObjects.Components. ComputedSize

Provides methods used for calculating and setting the size of a non-Frame based Game Object. Should be applied as a mixin and not used directly.

Since: 3.0.0
Source: src/gameobjects/components/ComputedSize.js (Line 7)

Members


displayHeight :number

The displayed height of this Game Object.

This value takes into account the scale factor.

Setting this value will adjust the Game Object's scale property.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/ComputedSize.js (Line 68)

displayWidth :number

The displayed width of this Game Object.

This value takes into account the scale factor.

Setting this value will adjust the Game Object's scale property.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/ComputedSize.js (Line 43)

height :number

The native (un-scaled) height of this Game Object.

Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayHeight property.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/ComputedSize.js (Line 30)

width :number

The native (un-scaled) width of this Game Object.

Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayWidth property.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/ComputedSize.js (Line 17)

Methods


setDisplaySize(width, height)

Sets the display size of this Game Object.

Calling this will adjust the scale.

Parameters:
Name Type Description
width number

The width of this Game Object.

height number

The height of this Game Object.

Since: 3.4.0
Source: src/gameobjects/components/ComputedSize.js (Line 120)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.ComputedSize

setSize(width, height)

Sets the internal size of this Game Object, as used for frame or physics body creation.

This will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or call the setDisplaySize method, which is the same thing as changing the scale but allows you to do so by giving pixel values.

If you have enabled this Game Object for input, changing the size will not change the size of the hit area. To do this you should adjust the input.hitArea object directly.

Parameters:
Name Type Description
width number

The width of this Game Object.

height number

The height of this Game Object.

Since: 3.4.0
Source: src/gameobjects/components/ComputedSize.js (Line 93)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.ComputedSize