Set the body on a Game Object to a rectangle.
Calling this methods resets previous properties you may have set on the body, including plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed.
name | type | arguments | description |
---|---|---|---|
width | number |
Width of the rectangle. |
|
height | number |
Height of the rectangle. |
|
options | Phaser.Types.Physics.Matter.MatterBodyConfig | <optional> |
An optional Body configuration object that is used to set initial Body properties on creation. |
This Game Object.
Set the body on a Game Object to a circle.
Calling this methods resets previous properties you may have set on the body, including plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed.
name | type | arguments | description |
---|---|---|---|
radius | number |
The radius of the circle. |
|
options | Phaser.Types.Physics.Matter.MatterBodyConfig | <optional> |
An optional Body configuration object that is used to set initial Body properties on creation. |
This Game Object.
Set the body on the Game Object to a polygon shape.
Calling this methods resets previous properties you may have set on the body, including plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed.
name | type | arguments | description |
---|---|---|---|
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. |
This Game Object.
Set the body on the Game Object to a trapezoid shape.
Calling this methods resets previous properties you may have set on the body, including plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed.
name | type | arguments | description |
---|---|---|---|
width | number |
The width of the trapezoid Body. |
|
height | number |
The height of the trapezoid Body. |
|
slope | number |
The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. |
|
options | Phaser.Types.Physics.Matter.MatterBodyConfig | <optional> |
An optional Body configuration object that is used to set initial Body properties on creation. |
This Game Object.
Set this Game Object to use the given existing Matter Body.
The body is first removed from the world before being added to this Game Object.
name | type | arguments | Default | description |
---|---|---|---|---|
body | MatterJS.BodyType |
The Body this Game Object should use. |
||
addToWorld | boolean | <optional> | true |
Should the body be immediately added to the World? |
This Game Object.
Set this Game Object to create and use a new Body based on the configuration object given.
Calling this method resets previous properties you may have set on the body, including plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed.
name | type | arguments | description |
---|---|---|---|
config | string | Phaser.Types.Physics.Matter.MatterSetBodyConfig |
Either a string, such as |
|
options | Phaser.Types.Physics.Matter.MatterBodyConfig | <optional> |
An optional Body configuration object that is used to set initial Body properties on creation. |
This Game Object.