Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Sleep
Phaser.Physics.Matter.Components.Sleep

Methods

setToSleep()
Focus
Focus

Description:

Sets this Body to sleep.

Returns:
Description:

This Game Object.

Examples:
Since: 3.22.0
Focus
Focus
setAwake()
Focus
Focus

Description:

Wakes this Body if asleep.

Returns:
Description:

This Game Object.

Examples:
Since: 3.22.0
Focus
Focus
setSleepThreshold([value])
Focus
Focus

Description:

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 arguments 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.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setSleepEvents(start, end)
Focus
Focus

Description:

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.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setSleepStartEvent(value)
Focus
Focus

Description:

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.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus
setSleepEndEvent(value)
Focus
Focus

Description:

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.

Returns:
Description:

This Game Object.

Examples:
Since: 3.0.0
Focus
Focus