API Docs for:
Show:

Polygon Class

Defined in: physics\Shapes.js:130

This shape represents a 2D polygon.

Constructor

Polygon

()

Item Index

Methods

addVertex

(
  • x
  • y
)

The positions of the vertices should be defined IN RELATION TO THE CENTER OF THE POLYGON. All vertices should be ADDED IN CLOCKWISE ORDER taking into account the coordinate system used by the engine.

Parameters:

  • x Number

    The vertex's x coordinate.

  • y Number

    The vertex's y coordinate.

clearVertices

()

Clears the vertex array.

getVertices

() Array

Returns the vertices of the polygon. Doesn't copy. Handle with care.

Returns:

Array: Vertices of the polygon.