Phaser API Documentation

fromVertices(x, y, vertexSets, [options], [flagInternal], [removeCollinear], [minimumArea])


Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes.


name type arguments Default description
x number

The X coordinate of the center of the Body.

y number

The Y coordinate of the center of the Body.

vertexSets string | array

The vertices data. Either a path string or an array of vertices.

options Phaser.Types.Physics.Matter.MatterBodyConfig <optional>

An optional Body configuration object that is used to set initial Body properties on creation.

flagInternal boolean <optional> false

Flag internal edges (coincident part edges)

removeCollinear number <optional> 0.01

Whether Matter.js will discard collinear edges (to improve performance).

minimumArea number <optional> 10

During decomposition discard parts that have an area less than this.


A Matter JS Body.

  • MatterJS.BodyType
Since: 3.0.0