Namespace: Mass

Phaser.Physics.Matter.Components. Mass

Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly.

Since: 3.0.0
Source: src/physics/matter-js/components/Mass.js (Line 10)

Members


<readonly> centerOfMass :Phaser.Math.Vector2

The body's center of mass.

Calling this creates a new `Vector2 each time to avoid mutation.

If you only need to read the value and won't change it, you can get it from GameObject.body.centerOfMass.

Type:
Since: 3.10.0
Source: src/physics/matter-js/components/Mass.js (Line 52)

Methods


setDensity(value)

Sets density of the body.

Parameters:
Name Type Description
value number

The new density of the body.

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

This Game Object.

Type
Phaser.GameObjects.GameObject

setMass(value)

Sets the mass of the Game Object's Matter Body.

Parameters:
Name Type Description
value number

The new mass of the body.

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

This Game Object.

Type
Phaser.GameObjects.GameObject