Phaser.Physics.Matter.Components.Sleep
Scope: static
Source: src/physics/matter-js/components/Sleep.js#L11
Since: 3.0.0
Static functions
setAwake
<instance> setAwake()
Description:
Wakes this physics body if it is currently asleep, returning it to active simulation. Once awake, the body will resume participating in collisions and physics updates.
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L41
Since: 3.22.0
setSleepEndEvent
<instance> setSleepEndEvent(value)
Description:
Enables or disables the Sleep End event for this body.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| value | boolean | No | true to enable the SLEEP_END event for this body, or false to disable it. |
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L129
Since: 3.0.0
setSleepEvents
<instance> setSleepEvents(start, end)
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 | optional | description |
|---|---|---|---|
| start | boolean | No | true if you want the sleep start event to be emitted for this body. |
| end | boolean | No | true if you want the sleep end event to be emitted for this body. |
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L76
Since: 3.0.0
setSleepStartEvent
<instance> setSleepStartEvent(value)
Description:
Enables or disables the Sleep Start event for this body.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| value | boolean | No | true to enable the SLEEP_START event for this body, or false to disable it. |
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L100
Since: 3.0.0
setSleepThreshold
<instance> setSleepThreshold([value])
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 | optional | default | description |
|---|---|---|---|---|
| value | number | Yes | 60 | The number of consecutive updates with near-zero velocity required before the body is put to sleep. |
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L57
Since: 3.0.0
setToSleep
<instance> setToSleep()
Description:
Immediately puts this physics body to sleep, removing it from active simulation. A sleeping body will not move, generate collisions, or consume CPU until it is woken. It can be woken manually via setAwake, or automatically when struck by another body.
Returns: Phaser.Physics.Matter.Components.Sleep - This Game Object instance.
Source: src/physics/matter-js/components/Sleep.js#L24
Since: 3.22.0