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

    The Matter.Bodies module contains factory methods for creating rigid body models with commonly used body configurations (such as rectangles, circles and other polygons).

    See the included usage examples.

    Index

    Constructors

    Methods

    • Creates a new rigid body model with a circle hull. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

      Parameters

      Returns MatterJS.BodyType

      A new circle body

      circle

    • Takes an array of Body objects and flags all internal edges (coincident parts) based on the maxDistance value. The array is changed in-place and returned, so you can pass this function a Body.parts property.

      Parameters

      • parts: MatterJS.BodyType[]

        The Body parts, or array of bodies, to flag.

      • OptionalmaxDistance: number

      Returns MatterJS.BodyType[]

      The modified parts parameter.

      flagCoincidentParts

    • Creates a body using the supplied vertices (or an array containing multiple sets of vertices). If the vertices are convex, they will pass through as supplied. Otherwise if the vertices are concave, they will be decomposed if poly-decomp.js is available. Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). By default the decomposition will discard collinear edges (to improve performance). It can also optionally discard any parts that have an area less than minimumArea. If the vertices can not be decomposed, the result will fall back to using the convex hull. The options parameter is an object that specifies any Matter.Body properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

      Parameters

      Returns MatterJS.BodyType

      fromVertices

    • Creates a new rigid body model with a regular polygon hull with the given number of sides. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

      Parameters

      Returns MatterJS.BodyType

      A new regular polygon body

      polygon

    • Creates a new rigid body model with a rectangle hull. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

      Parameters

      Returns MatterJS.BodyType

      A new rectangle body

      rectangle

    • Creates a new rigid body model with a trapezoid hull. The slope is parameterised as a fraction of width and must be < 1 to form a valid trapezoid. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

      Parameters

      Returns MatterJS.BodyType

      A new trapezoid body

      trapezoid