The Matter.Engine module contains methods for creating and manipulating engines. An engine is a controller that manages updating the simulation of the world. See Matter.Runner for an optional game loop utility.

See the included usage examples.

Hierarchy

  • default

Constructors

Properties

run: ((target, engine?) => IRunner) = Runner.run

Type declaration

Methods

  • Applies gravitational acceleration to all bodies. This models a uniform gravitational field, similar to near the surface of a planet.

    Parameters

    Returns void

    Method

    _bodiesApplyGravity

  • Zeroes the body.force and body.torque force buffers.

    Parameters

    Returns void

    Method

    _bodiesClearForces

  • Applies Body.update to all given bodies.

    Parameters

    • bodies: IBody[]
    • delta: number

      The amount of time elapsed between updates

    Returns void

    Method

    _bodiesUpdate

  • Applies Body.updateVelocities to all given bodies.

    Parameters

    Returns void

    Method

    _bodiesUpdateVelocities

  • Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. All properties have default values, and many are pre-calculated automatically based on other properties. See the properties section below for detailed information on what you can pass via the options object.

    Parameters

    Returns IEngine

    engine

    Method

    create

  • Merges two engines by keeping the configuration of engineA but replacing the world with the one from engineB.

    Parameters

    Returns void

    Method

    merge

  • Moves the simulation forward in time by delta milliseconds. Triggers beforeUpdate, beforeSolve and afterUpdate events. Triggers collisionStart, collisionActive and collisionEnd events.

    Parameters

    • engine: IEngine
    • delta: number = Common._baseDelta

    Returns IEngine

    Method

    update

Generated using TypeDoc