Phaser API Documentation

  Version: 
rectangle(x, y, width, height, [options])

Description:

Creates a new rigid rectangular 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.

width number

The width of the Body.

height number

The height of the Body.

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