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.
-
setSleepEndEvent(value)
-
Enables or disables the Sleep End event for this body.
Parameters:
Name Type Description valueboolean trueto enable the sleep event, orfalseto disable it.- Since: 3.0.0
- Source: src/physics/matter-js/components/Sleep.js (Line 117)
Returns:
This Game Object.
-
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_STARTandSLEEP_ENDevents.Parameters:
Name Type Description startboolean trueif you want the sleep start event to be emitted for this body.endboolean trueif 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.
-
setSleepStartEvent(value)
-
Enables or disables the Sleep Start event for this body.
Parameters:
Name Type Description valueboolean trueto enable the sleep event, orfalseto disable it.- Since: 3.0.0
- Source: src/physics/matter-js/components/Sleep.js (Line 88)
Returns:
This Game Object.
-
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 valuenumber <optional>
60 A
Numberthat 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.
-
setToSleep()
-
Sets this Body to sleep.
- Since: 3.22.0
- Source: src/physics/matter-js/components/Sleep.js (Line 19)
Returns:
This Game Object.
