Phaser API Documentation

  Version: 
polygon(x, y, sides, radius, [options])

Description:

Creates a new rigid polygonal Body and adds it to the World.

Parameters:

name type arguments description
x number

The X coordinate of the center of the Body.

y number

The Y coordinate of the center of the Body.

sides number

The number of sides the polygon will have.

radius number

The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle.

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

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

Returns:
Description:

A Matter JS Body.

Type:
  • MatterJS.BodyType
Since: 3.0.0