Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Velocity
Phaser.Physics.Arcade.Components.Velocity

Methods

setVelocity(x, [y])
Focus
Focus

Description:

Sets the velocity of the Body.

Parameters:

name type arguments Default description
x number

The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left.

y number <optional> x

The vertical velocity of the body. Positive values move the body down, while negative values move it up.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setVelocityX(x)
Focus
Focus

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:

name type description
x number

The new horizontal velocity.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setVelocityY(y)
Focus
Focus

Description:

Sets the vertical component of the body's velocity.

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

Parameters:

name type description
y number

The new vertical velocity of the body.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setMaxVelocity(x, [y])
Focus
Focus

Description:

Sets the maximum velocity of the body.

Parameters:

name type arguments Default description
x number

The new maximum horizontal velocity.

y number <optional> x

The new maximum vertical velocity.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus