Namespace: Size

Phaser.Physics.Arcade.Components. Size

Provides methods for setting the size of an Arcade Physics Game Object. Should be applied as a mixin and not used directly.

Since: 3.0.0
Source: src/physics/arcade/components/Size.js (Line 7)

Methods


setBodySize(width, height [, center])

Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.

Parameters:
Name Type Argument Default Description
width number

The new width of the physics body, in pixels.

height number

The new height of the physics body, in pixels.

center boolean <optional>
true

Should the body be re-positioned so its center aligns with the parent Game Object?

Since: 3.24.0
Source: src/physics/arcade/components/Size.js (Line 57)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Size

setCircle(radius [, offsetX] [, offsetY])

Sets this physics body to use a circle for collision instead of a rectangle.

Parameters:
Name Type Argument Description
radius number

The radius of the physics body, in pixels.

offsetX number <optional>

The amount to offset the body from the parent Game Object along the x-axis.

offsetY number <optional>

The amount to offset the body from the parent Game Object along the y-axis.

Since: 3.0.0
Source: src/physics/arcade/components/Size.js (Line 76)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Size

setOffset(x [, y])

Sets the body offset. This allows you to adjust the difference between the center of the body and the x and y coordinates of the parent Game Object.

Parameters:
Name Type Argument Default Description
x number

The amount to offset the body from the parent Game Object along the x-axis.

y number <optional>
x

The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis.

Since: 3.0.0
Source: src/physics/arcade/components/Size.js (Line 16)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Size

setSize(width, height [, center])

DEPRECATED: Please use setBodySize instead.

Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.

Parameters:
Name Type Argument Default Description
width number

The new width of the physics body, in pixels.

height number

The new height of the physics body, in pixels.

center boolean <optional>
true

Should the body be re-positioned so its center aligns with the parent Game Object?

Since: 3.0.0
Deprecated:
  • Yes
Source: src/physics/arcade/components/Size.js (Line 35)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Size