These archived docs are for Phaser 2.2.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

## Constructor

#### new Body(sprite)

The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.

##### Parameters
Name Type Description
`sprite` Phaser.Sprite

The Sprite object this physics body belongs to.

### Public Properties

#### acceleration : Phaser.Point

The velocity in pixels per second sq. of the Body.

#### allowGravity : boolean

Allow this Body to be influenced by gravity? Either world or local.

Default Value
• true

#### allowRotation : boolean

Allow this Body to be rotated? (via angularVelocity, etc)

Default Value
• true

The angle of the Body in radians as calculated by its velocity, rather than its visual angle.

#### angularAcceleration : number

The angular acceleration in pixels per second sq. of the Body.

Default Value
• 0

#### angularDrag : number

The angular drag applied to the rotation of the Body.

Default Value
• 0

#### angularVelocity : number

The angular velocity in pixels per second sq. of the Body.

Default Value
• 0

#### blocked : Object

This object is populated with boolean values when the Body collides with the World bounds or a Tile. For example if blocked.up is true then the Body cannot move up. An object containing on which faces this Body is blocked from moving, if any.

The bottom value of this Body (same as Body.y + Body.height)

#### bounce : Phaser.Point

The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.

#### center : Phaser.Point

The center coordinate of the Physics Body.

#### checkCollision : Object

Set the checkCollision properties to control which directions collision is processed for this Body. For example checkCollision.up = false means it won't collide when the collision happened while moving up. An object containing allowed collision.

#### collideWorldBounds : boolean

A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. Should the Body collide with the World bounds?

#### customSeparateX : boolean

This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one?

Default Value
• false

#### customSeparateY : boolean

This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one?

Default Value
• false

#### deltaMax : Phaser.Point

The Sprite position is updated based on the delta x/y values. You can set a cap on those (both +-) using deltaMax.

#### drag : Phaser.Point

The drag applied to the motion of the Body.

#### embedded : boolean

If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true. Body embed value.

#### enable : boolean

A disabled body won't be checked for any form of collision or overlap or have its pre/post updates run.

Default Value
• true

#### facing : number

A const reference to the direction the Body is traveling or facing.

#### game : Phaser.Game

Local reference to game.

#### gravity : Phaser.Point

A local gravity applied to this Body. If non-zero this over rides any world gravity, unless Body.allowGravity is set to false.

#### halfHeight : number

The calculated height / 2 of the physics body.

#### halfWidth : number

The calculated width / 2 of the physics body.

#### height

##### Properties:
Name Type Description
`.numInternal`

ID cache

#### immovable : boolean

An immovable Body will not receive any impacts from other bodies.

Default Value
• false

#### mass : number

The mass of the Body.

Default Value
• 1

#### maxAngular : number

The maximum angular velocity in pixels per second sq. that the Body can reach.

Default Value
• 1000

#### maxVelocity : Phaser.Point

The maximum velocity in pixels per second sq. that the Body can reach.

#### moves : boolean

If you have a Body that is being moved around the world via a tween or a Group motion, but its local x/y position never actually changes, then you should set Body.moves = false. Otherwise it will most likely fly off the screen. If you want the physics system to move the body around, then set moves to true. Set to true to allow the Physics system to move this Body, other false to move it manually.

Default Value
• true

New velocity.

#### offset : Phaser.Point

The offset of the Physics Body from the Sprite x/y position.

#### overlapX : number

When this body collides with another, the amount of overlap is stored here. The amount of horizontal overlap during the collision.

#### overlapY : number

When this body collides with another, the amount of overlap is stored here. The amount of vertical overlap during the collision.

#### phase

##### Properties:
Name Type Description
`phaser` number

Is this Body in a preUpdate (1) or postUpdate (2) state?

The position of the physics body.

The previous rotation of the physics body.

The previous position of the physics body.

The right value of this Body (same as Body.x + Body.width)

#### rotation : number

The amount the Body is rotated.

If true and you collide this Sprite against a Group, it will disable the collision check from using a QuadTree.

The un-scaled original size.

The un-scaled original size.

The speed of the Body as calculated by its velocity.

#### sprite : Phaser.Sprite

Reference to the parent Sprite.

If this is an especially small or fast moving object then it can sometimes skip over tilemap collisions if it moves through a tile in a step. Set this padding value to add extra padding to its bounds. tilePadding.x applied to its width, y to its height. Extra padding to be added to this sprites dimensions when checking for tile collision.

#### touching : Object

This object is populated with boolean values when the Body collides with another. touching.up = true means the collision happened to the top of this Body for example. An object containing touching results.

#### type : number

The type of physics system this body belongs to.

#### velocity : Phaser.Point

The velocity in pixels per second sq. of the Body.

#### wasTouching : Object

This object is populated with previous touching values from the bodies previous collision. An object containing previous touching results.

#### width : number

The calculated width of the physics body.

The x position.

The y position.

### Public Methods

#### <internal> checkWorldBounds()

Internal method.

Internal:
• This member is internal (protected) and may be modified or removed in the future.

#### deltaAbsX() → {number}

Returns the absolute delta x value.

##### Returns
number -

The absolute delta value.

#### deltaAbsY() → {number}

Returns the absolute delta y value.

##### Returns
number -

The absolute delta value.

#### deltaX() → {number}

Returns the delta x value. The difference between Body.x now and in the previous step.

##### Returns
number -

The delta value. Positive if the motion was to the right, negative if to the left.

#### deltaY() → {number}

Returns the delta y value. The difference between Body.y now and in the previous step.

##### Returns
number -

The delta value. Positive if the motion was downwards, negative if upwards.

#### deltaZ() → {number}

Returns the delta z value. The difference between Body.rotation now and in the previous step.

##### Returns
number -

The delta value. Positive if the motion was clockwise, negative if anti-clockwise.

#### destroy()

Removes this bodies reference to its parent sprite, freeing it up for gc.

#### hitTest(x, y) → {boolean}

Tests if a world point lies within this Body.

##### Parameters
Name Type Description
`x` number

The world x coordinate to test.

`y` number

The world y coordinate to test.

##### Returns
boolean -

True if the given coordinates are inside this Body, otherwise false.

#### onFloor() → {boolean}

Returns true if the bottom of this Body is in contact with either the world bounds or a tile.

##### Returns
boolean -

True if in contact with either the world bounds or a tile.

#### onWall() → {boolean}

Returns true if either side of this Body is in contact with either the world bounds or a tile.

##### Returns
boolean -

True if in contact with either the world bounds or a tile.

#### <internal> postUpdate()

Internal method.

Internal:
• This member is internal (protected) and may be modified or removed in the future.

#### <internal> preUpdate()

Internal method.

Internal:
• This member is internal (protected) and may be modified or removed in the future.

#### render(context, body, color, filled)

Render Sprite Body.

##### Parameters
Name Type Argument Default Description
`context` object

The context to render to.

`body` Phaser.Physics.Arcade.Body

The Body to render the info of.

`color` string <optional>
'rgba(0,255,0,0.4)'

color of the debug info to be rendered. (format is css color string).

`filled` boolean <optional>
true

Render the objected as a filled (default, true) or a stroked (false)

#### renderBodyInfo(body, x, y, color)

Render Sprite Body Physics Data as text.

##### Parameters
Name Type Argument Default Description
`body` Phaser.Physics.Arcade.Body

The Body to render the info of.

`x` number

X position of the debug info to be rendered.

`y` number

Y position of the debug info to be rendered.

`color` string <optional>
'rgb(255,255,255)'

color of the debug info to be rendered. (format is css color string).

#### reset(x, y)

Resets all Body values (velocity, acceleration, rotation, etc)

##### Parameters
Name Type Description
`x` number

The new x position of the Body.

`y` number

The new y position of the Body.

#### setSize(width, height, offsetX, offsetY)

You can modify the size of the physics Body to be any dimension you need. So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite.

##### Parameters
Name Type Argument Description
`width` number

The width of the Body.

`height` number

The height of the Body.

`offsetX` number <optional>

The X offset of the Body from the Sprite position.

`offsetY` number <optional>

The Y offset of the Body from the Sprite position.