You’re reading the docs for Phaser v3.88.2. The latest is Phaser v4.1.0.

Phaser.Physics.Arcade.Components.Velocity

Scope: static

Source: src/physics/arcade/components/Velocity.js#L7
Since: 3.0.0

Static functions

setMaxVelocity

instancesetMaxVelocity(x, [y])

Description:

Sets the maximum velocity of the body.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe new maximum horizontal velocity, in pixels per second.
ynumberYes"x"The new maximum vertical velocity, in pixels per second.

Returns: Phaser.Physics.Arcade.Components.Velocity - This Game Object.

Source: src/physics/arcade/components/Velocity.js#L73
Since: 3.0.0


setVelocity

instancesetVelocity(x, [y])

Description:

Sets the velocity of the Body.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe horizontal velocity of the body, in pixels per second. Positive values move the body to the right, while negative values move it to the left.
ynumberYes"x"The vertical velocity of the body, in pixels per second. Positive values move the body down, while negative values move it up.

Returns: Phaser.Physics.Arcade.Components.Velocity - This Game Object.

Source: src/physics/arcade/components/Velocity.js#L17
Since: 3.0.0


setVelocityX

instancesetVelocityX(x)

Description:

Sets the horizontal component of the body's velocity.

Positive values move the body to the right, while negative values move it to the left.

Parameters:

nametypeoptionaldescription
xnumberNoThe new horizontal velocity, in pixels per second.

Returns: Phaser.Physics.Arcade.Components.Velocity - This Game Object.

Source: src/physics/arcade/components/Velocity.js#L35
Since: 3.0.0


setVelocityY

instancesetVelocityY(y)

Description:

Sets the vertical component of the body's velocity.

Positive values move the body down, while negative values move it up.

Parameters:

nametypeoptionaldescription
ynumberNoThe new vertical velocity, in pixels per second.

Returns: Phaser.Physics.Arcade.Components.Velocity - This Game Object.

Source: src/physics/arcade/components/Velocity.js#L54
Since: 3.0.0