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

    Provides methods used for setting the bounce properties of an Arcade Physics Body.

    interface Bounce {
        setBounce(x: number, y?: number): this;
        setBounceX(value: number): this;
        setBounceY(value: number): this;
        setCollideWorldBounds(
            value?: boolean,
            bounceX?: number,
            bounceY?: number,
            onWorldBounds?: boolean,
        ): this;
    }

    Implemented by

    Index

    Methods

    • Sets the bounce values of this body.

      Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all.

      Parameters

      • x: number

        The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1.

      • Optionaly: number

        The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x.

      Returns this

    • Sets the horizontal bounce value for this body.

      Parameters

      • value: number

        The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1.

      Returns this

    • Sets the vertical bounce value for this body.

      Parameters

      • value: number

        The amount of vertical bounce to apply on collision. A float, typically between 0 and 1.

      Returns this

    • Sets whether this Body collides with the world boundary.

      Optionally also sets the World Bounce values. If the Body.worldBounce is null, it's set to a new Phaser.Math.Vector2 first.

      Parameters

      • Optionalvalue: boolean

        true if this body should collide with the world bounds, otherwise false. Default true.

      • OptionalbounceX: number

        If given this will be replace the worldBounce.x value.

      • OptionalbounceY: number

        If given this will be replace the worldBounce.y value.

      • OptionalonWorldBounds: boolean

        If given this replaces the Body's onWorldBounds value.

      Returns this