phaser - v4.0.0-rc.4
    Preparing search index...

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

    interface Sleep {
        setAwake(): this;
        setSleepEndEvent(value: boolean): this;
        setSleepEvents(start: boolean, end: boolean): this;
        setSleepStartEvent(value: boolean): this;
        setSleepThreshold(value?: number): this;
        setToSleep(): this;
    }

    Implemented by

    Index

    Methods

    • Enables or disables the Sleep End event for this body.

      Parameters

      • value: boolean

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

      Returns this

    • 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

      • 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 this

    • Enables or disables the Sleep Start event for this body.

      Parameters

      • value: boolean

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

      Returns this

    • 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

      • Optionalvalue: number

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

      Returns this