Class: Body

Phaser.Physics.Arcade. Body

Arcade Physics Body 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.

Source:

Members

acceleration

Properties:
Name Type Description
acceleration Phaser.Point

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

Source:

allowCollision

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

Properties:
Name Type Description
allowCollision object

An object containing allowed collision.

Source:

allowGravity

Properties:
Name Type Description
allowGravity boolean

Allow this Body to be influenced by the global Gravity?

Default Value:
  • true
Source:

allowRotation

Properties:
Name Type Description
allowRotation boolean

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

Default Value:
  • true
Source:

angularAcceleration

Properties:
Name Type Description
angularAcceleration number

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

Default Value:
  • 0
Source:

angularDrag

Properties:
Name Type Description
angularDrag number

The angular drag applied to the rotation of the Body.

Default Value:
  • 0
Source:

angularVelocity

Properties:
Name Type Description
angularVelocity number

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

Default Value:
  • 0
Source:

bottom

Properties:
Name Type Description
bottom number

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

Source:

bounce

Properties:
Name Type Description
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.

Source:

center

Properties:
Name Type Description
center Phaser.Point

The center coordinate of the Physics Body.

Source:

collideWorldBounds

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.

Properties:
Name Type Description
collideWorldBounds boolean

Should the Body collide with the World bounds?

Source:

customSeparateX

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.

Properties:
Name Type Description
customSeparateX boolean

Use a custom separation system or the built-in one?

Default Value:
  • false
Source:

customSeparateY

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.

Properties:
Name Type Description
customSeparateY boolean

Use a custom separation system or the built-in one?

Default Value:
  • false
Source:

drag

Properties:
Name Type Description
drag Phaser.Point

The drag applied to the motion of the Body.

Source:

embedded

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.

Properties:
Name Type Description
embedded boolean

Body embed value.

Source:

facing

Properties:
Name Type Description
facing number

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

Source:

game

Properties:
Name Type Description
game Phaser.Game

Local reference to game.

Source:

gravity

Properties:
Name Type Description
gravity Phaser.Point

A private Gravity setting for the Body.

Source:

halfHeight

Properties:
Name Type Description
halfHeight number

The calculated height / 2 of the physics body.

Source:

halfWidth

Properties:
Name Type Description
halfWidth number

The calculated width / 2 of the physics body.

Source:

height

Properties:
Name Type Description
.numInternal

ID cache

Source:

hullX

Properties:
Name Type Description
hullX Phaser.Rectangle

The dynamically calculated hull used during collision.

Source:

hullY

Properties:
Name Type Description
hullY Phaser.Rectangle

The dynamically calculated hull used during collision.

Source:

immovable

Properties:
Name Type Description
immovable boolean

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

Default Value:
  • false
Source:

mass

Properties:
Name Type Description
mass number

The mass of the Body.

Default Value:
  • 1
Source:

maxAngular

Properties:
Name Type Description
maxAngular number

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

Default Value:
  • 1000
Source:

maxVelocity

Properties:
Name Type Description
maxVelocity Phaser.Point

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

Source:

moves

Properties:
Name Type Description
moves boolean

Set to true to allow the Physics system to move this Body, other false to move it manually.

Default Value:
  • true
Source:

offset

Properties:
Name Type Description
offset Phaser.Point

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

Source:

overlapX

When this body collides with another, the amount of overlap is stored here.

Properties:
Name Type Description
overlapX number

The amount of horizontal overlap during the collision.

Source:

overlapY

When this body collides with another, the amount of overlap is stored here.

Properties:
Name Type Description
overlapY number

The amount of vertical overlap during the collision.

Source:

<readonly> preRotation

Properties:
Name Type Description
preRotation number

The previous rotation of the physics body.

Source:

<readonly> preX

Properties:
Name Type Description
preX number

The previous x position of the physics body.

Source:

<readonly> preY

Properties:
Name Type Description
preY number

The previous y position of the physics body.

Source:

<protected> quadTreeIDs

Properties:
Name Type Description
quadTreeIDs Array

Internal ID cache.

Source:

<protected> quadTreeIndex

Properties:
Name Type Description
quadTreeIndex number

Internal ID cache.

Source:
Properties:
Name Type Description
right number

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

Source:

rotation

Properties:
Name Type Description
rotation number

The amount the Body is rotated.

Default Value:
  • 0
Source:

<readonly> screenX

Properties:
Name Type Description
screenX number

The x position of the physics body translated to screen space.

Source:

<readonly> screenY

Properties:
Name Type Description
screenY number

The y position of the physics body translated to screen space.

Source:

skipQuadTree

Properties:
Name Type Description
skipQuadTree boolean

If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree.

Default Value:
  • false
Source:

<readonly> sourceHeight

Properties:
Name Type Description
sourceHeight number

The un-scaled original size.

Source:

<readonly> sourceWidth

Properties:
Name Type Description
sourceWidth number

The un-scaled original size.

Source:

sprite

Properties:
Name Type Description
sprite Phaser.Sprite

Reference to the parent Sprite.

Source:

touching

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.

Properties:
Name Type Description
touching object

An object containing touching results.

Source:

velocity

Properties:
Name Type Description
velocity Phaser.Point

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

Source:

wasTouching

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

Properties:
Name Type Description
wasTouching object

An object containing previous touching results.

Source:

width

Properties:
Name Type Description
width number

The calculated width of the physics body.

Source:

<readonly> x

Properties:
Name Type Description
x number

The x position of the physics body.

Source:

<readonly> y

Properties:
Name Type Description
y number

The y position of the physics body.

Source:

Methods

deltaAbsX() → {number}

Returns the absolute delta x value.

Source:
Returns:

The absolute delta value.

Type
number

deltaAbsY() → {number}

Returns the absolute delta y value.

Source:
Returns:

The absolute delta value.

Type
number

deltaX() → {number}

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

Source:
Returns:

The delta value.

Type
number

deltaY() → {number}

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

Source:
Returns:

The delta value.

Type
number
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template.