PokéRogue
    Preparing search index...

    The Force component provides methods for applying forces and directional thrust to a Matter.js physics body. It is mixed into Game Objects that use Matter.js physics, giving them the ability to simulate impulses and continuous forces. All thrust methods derive direction from the body's current rotation angle, making them well-suited for top-down vehicles, spaceships, or any entity that moves relative to the direction it is facing. Use very small force values to avoid unrealistic acceleration.

    interface Force {
        applyForce(force: Vector2): this;
        applyForceFrom(position: Vector2, force: Vector2): this;
        thrust(speed: number): this;
        thrustBack(speed: number): this;
        thrustLeft(speed: number): this;
        thrustRight(speed: number): this;
    }

    Implemented by

    Index
    • Applies a force to a body at its current center of mass position.

      Parameters

      • force: Vector2

        A Vector that specifies the force to apply.

      Returns this

      This Game Object instance.

    • Applies a force to a body from a given position.

      Parameters

      • position: Vector2

        The position in which the force comes from.

      • force: Vector2

        A Vector that specifies the force to apply.

      Returns this

      This Game Object instance.

    • Apply thrust in the forward direction of the body.

      Use very small values, such as 0.1, depending on the mass and required speed.

      Parameters

      • speed: number

        A speed value to be applied to a directional force.

      Returns this

      This Game Object instance.

    • Apply thrust in the reverse direction of the body.

      Use very small values, such as 0.1, depending on the mass and required speed.

      Parameters

      • speed: number

        A speed value to be applied to a directional force.

      Returns this

      This Game Object instance.

    • Apply thrust in the left direction of the body.

      Use very small values, such as 0.1, depending on the mass and required speed.

      Parameters

      • speed: number

        A speed value to be applied to a directional force.

      Returns this

      This Game Object instance.

    • Apply thrust in the right direction of the body.

      Use very small values, such as 0.1, depending on the mass and required speed.

      Parameters

      • speed: number

        A speed value to be applied to a directional force.

      Returns this

      This Game Object instance.