Skip to main content
Version: Phaser v4.0.0

Phaser.Physics.Matter.Components.Transform

Scope: static

Source: src/physics/matter-js/components/Transform.js#L17
Since: 3.0.0

Static functions

angle

angle: number

Description:

Use angle to set or get the rotation of the physics body associated with this Game Object. Unlike rotation, when setting this value it is specified in degrees, which are converted to radians internally.

Source: src/physics/matter-js/components/Transform.js#L174
Since: 3.0.0


rotation

rotation: number

Description:

Use rotation to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians.

Source: src/physics/matter-js/components/Transform.js#L196
Since: 3.0.0


scale

scale: number

Description:

This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object to the same value, at the same time. When reading this value the result returned is (scaleX + scaleY) / 2.

Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this isn't the case, use the scaleX or scaleY properties instead.

Source: src/physics/matter-js/components/Transform.js#L74
Since: 3.88.0


scaleX

scaleX: number

Description:

The horizontal scale of this Game Object.

Source: src/physics/matter-js/components/Transform.js#L99
Since: 3.0.0


scaleY

scaleY: number

Description:

The vertical scale of this Game Object.

Source: src/physics/matter-js/components/Transform.js#L137
Since: 3.0.0


x

x: number

Description:

The x position of this Game Object.

Source: src/physics/matter-js/components/Transform.js#L28
Since: 3.0.0


y

y: number

Description:

The y position of this Game Object.

Source: src/physics/matter-js/components/Transform.js#L51
Since: 3.0.0


Static functions

setAngle

<instance> setAngle([degrees])

Description:

Immediately sets the angle of the Body. Angular velocity, position, force etc. are unchanged.

Parameters:

nametypeoptionaldefaultdescription
degreesnumberYes0The angle to set, in degrees.

Returns: Phaser.Physics.Matter.Components.Transform - This Game Object instance.

Source: src/physics/matter-js/components/Transform.js#L283
Since: 3.0.0


setFixedRotation

<instance> setFixedRotation()

Description:

Setting fixed rotation sets the Body inertia to Infinity, which stops it from being able to rotate when forces are applied to it.

Returns: Phaser.Physics.Matter.Components.Transform - This Game Object instance.

Source: src/physics/matter-js/components/Transform.js#L267
Since: 3.0.0


setPosition

<instance> setPosition([x], [y])

Description:

Sets the position of the physics body along the x and y axes. Both parameters are optional and default to 0 if not provided. Velocity, angle, force etc. are unchanged.

Parameters:

nametypeoptionaldefaultdescription
xnumberYes0The horizontal position of the body.
ynumberYes"x"The vertical position of the body.

Returns: Phaser.Physics.Matter.Components.Transform - This Game Object instance.

Source: src/physics/matter-js/components/Transform.js#L220
Since: 3.0.0


setRotation

<instance> setRotation([radians])

Description:

Immediately sets the angle of the Body. Angular velocity, position, force etc. are unchanged.

Parameters:

nametypeoptionaldefaultdescription
radiansnumberYes0The angle of the body, in radians.

Returns: Phaser.Physics.Matter.Components.Transform - This Game Object instance.

Source: src/physics/matter-js/components/Transform.js#L245
Since: 3.0.0


setScale

<instance> setScale([x], [y], [point])

Description:

Sets the scale of this Game Object and its underlying Matter.js physics body. The optional point parameter specifies the origin from which scaling will occur. If omitted, scaling is applied from the body's current position.

Parameters:

nametypeoptionaldefaultdescription
xnumberYes1The horizontal scale of this Game Object.
ynumberYes"x"The vertical scale of this Game Object. If not set it will use the x value.
pointPhaser.Math.Vector2YesThe point (Vector2) from which scaling will occur.

Returns: Phaser.Physics.Matter.Components.Transform - This Game Object instance.

Source: src/physics/matter-js/components/Transform.js#L305
Since: 3.0.0