Phaser API Documentation

  Version: 
Filter
Namespace: Velocity
Phaser.Physics.Matter.Components.Velocity

Methods

setVelocityX(x)
Focus
Focus

Description:

Sets the horizontal velocity of the physics body.

Parameters:

name type description
x number

The horizontal velocity value.

Returns:
Description:

This Game Object instance.

Since: 3.0.0
Focus
Focus
setVelocityY(y)
Focus
Focus

Description:

Sets vertical velocity of the physics body.

Parameters:

name type description
y number

The vertical velocity value.

Returns:
Description:

This Game Object instance.

Since: 3.0.0
Focus
Focus
setVelocity(x, [y])
Focus
Focus

Description:

Sets both the horizontal and vertical velocity of the physics body.

Parameters:

name type arguments Default description
x number

The horizontal velocity value.

y number <optional> x

The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the x value.

Returns:
Description:

This Game Object instance.

Since: 3.0.0
Focus
Focus
getVelocity()
Focus
Focus

Description:

Gets the current linear velocity of the physics body.

Returns:
Description:

The current linear velocity of the body.

Since: 3.60.0
Focus
Focus
setAngularVelocity(velocity)
Focus
Focus

Description:

Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged.

Parameters:

name type description
velocity number

The angular velocity.

Returns:
Description:

This Game Object instance.

Since: 3.0.0
Focus
Focus
getAngularVelocity()
Focus
Focus

Description:

Gets the current rotational velocity of the body.

Returns:
Description:

The current angular velocity of the body.

Type:
  • number
Since: 3.60.0
Focus
Focus
setAngularSpeed(speed)
Focus
Focus

Description:

Sets the current rotational speed of the body. Direction is maintained. Affects body angular velocity.

Parameters:

name type description
speed number

The angular speed.

Returns:
Description:

This Game Object instance.

Since: 3.60.0
Focus
Focus
getAngularSpeed()
Focus
Focus

Description:

Gets the current rotational speed of the body. Equivalent to the magnitude of its angular velocity.

Returns:
Description:

The current angular velocity of the body.

Type:
  • number
Since: 3.60.0
Focus
Focus