Namespace: Sleep

Phaser.Physics.Matter.Components. Sleep

Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly.

Since: 3.0.0
Source: src/physics/matter-js/components/Sleep.js (Line 11)

Methods


setAwake()

Wakes this Body if asleep.

Since: 3.22.0
Source: src/physics/matter-js/components/Sleep.js (Line 32)
Returns:

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep

setSleepEndEvent(value)

Enables or disables the Sleep End event for this body.

Parameters:
Name Type Description
value boolean

true to enable the sleep event, or false to disable it.

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

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep

setSleepEvents(start, end)

Enable sleep and wake events for this body.

By default when a body goes to sleep, or wakes up, it will not emit any events.

The events are emitted by the Matter World instance and can be listened to via the SLEEP_START and SLEEP_END events.

Parameters:
Name Type Description
start boolean

true if you want the sleep start event to be emitted for this body.

end boolean

true if you want the sleep end event to be emitted for this body.

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

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep

setSleepStartEvent(value)

Enables or disables the Sleep Start event for this body.

Parameters:
Name Type Description
value boolean

true to enable the sleep event, or false to disable it.

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

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep

setSleepThreshold( [value])

Sets the number of updates in which this body must have near-zero velocity before it is set as sleeping (if sleeping is enabled by the engine).

Parameters:
Name Type Argument Default Description
value number <optional>
60

A Number that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping.

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

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep

setToSleep()

Sets this Body to sleep.

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

This Game Object.

Type
Phaser.Physics.Matter.Components.Sleep