Namespace: Velocity

Phaser.Physics.Arcade.Components. Velocity

Provides methods for modifying the velocity of an Arcade Physics body.

Should be applied as a mixin and not used directly.

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

Methods


setMaxVelocity(x [, y])

Sets the maximum velocity of the body.

Parameters:
Name Type Argument Default Description
x number

The new maximum horizontal velocity.

y number <optional>
x

The new maximum vertical velocity.

Since: 3.0.0
Source: src/physics/arcade/components/Velocity.js (Line 73)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Velocity

setVelocity(x [, y])

Sets the velocity of the Body.

Parameters:
Name Type Argument 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.

Since: 3.0.0
Source: src/physics/arcade/components/Velocity.js (Line 17)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Velocity

setVelocityX(x)

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.

Since: 3.0.0
Source: src/physics/arcade/components/Velocity.js (Line 35)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Velocity

setVelocityY(y)

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.

Since: 3.0.0
Source: src/physics/arcade/components/Velocity.js (Line 54)
Returns:

This Game Object.

Type
Phaser.Physics.Arcade.Components.Velocity