Namespace: Force

Phaser.Physics.Matter.Components. Force

A component to apply force to Matter.js bodies.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 9)

Methods


applyForce(force)

Applies a force to a body.

Parameters:
Name Type Description
force Phaser.Math.Vector2

A Vector that specifies the force to apply.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 19)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject

applyForceFrom(position, force)

Applies a force to a body from a given position.

Parameters:
Name Type Description
position Phaser.Math.Vector2

The position in which the force comes from.

force Phaser.Math.Vector2

A Vector that specifies the force to apply.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 38)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject

thrust(speed)

Apply thrust to the forward position of the body.

Parameters:
Name Type Description
speed number

A speed value to be applied to a directional force.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 56)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject

thrustBack(speed)

Apply thrust to the back position of the body.

Parameters:
Name Type Description
speed number

A speed value to be applied to a directional force.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 119)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject

thrustLeft(speed)

Apply thrust to the left position of the body.

Parameters:
Name Type Description
speed number

A speed value to be applied to a directional force.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 77)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject

thrustRight(speed)

Apply thrust to the right position of the body.

Parameters:
Name Type Description
speed number

A speed value to be applied to a directional force.

Since: 3.0.0
Source: src/physics/matter-js/components/Force.js (Line 98)
Returns:

This Game Object.

Type
Phaser.GameObjects.GameObject