Class: Body

Phaser.Physics.Arcade. Body

A Dynamic Arcade Body.

Its static counterpart is Phaser.Physics.Arcade.StaticBody.


new Body(world, gameObject)

Parameters:
Name Type Description
world Phaser.Physics.Arcade.World

The Arcade Physics simulation this Body belongs to.

gameObject Phaser.GameObjects.GameObject

The Game Object this Body belongs to.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 35)

Members


acceleration :Phaser.Math.Vector2

The Body's change in velocity, in pixels per second squared.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 317)

allowDrag :boolean

Whether this Body's velocity is affected by its drag.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 326)

allowGravity :boolean

Whether this Body's position is affected by gravity (local or world).

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 353)
See:

allowRotation :boolean

Whether this Body's rotation is affected by its angular acceleration and angular velocity.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 181)

angle :number

The calculated angle of this Body's velocity vector, in degrees, during the last step.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 537)

angularAcceleration :number

The Body's angular acceleration (change in angular velocity), in degrees per second squared.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 494)

angularDrag :number

Loss of angular velocity due to angular movement, in degrees per second.

Angular drag is applied only when angular acceleration is zero.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 504)

angularVelocity :number

The rate of change of this Body's rotation, in degrees per second.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 484)

blocked :ArcadeBodyCollision

Whether this Body is colliding with a tile or the world boundary.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 687)

<readonly> bottom :number

The bottom edge of this Body's boundary.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2106)

bounce :Phaser.Math.Vector2

Rebound following a collision, relative to 1.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 376)

center :Phaser.Math.Vector2

The center of the Body's boundary. The midpoint of its position (top-left corner) and its bottom-right corner.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 279)

checkCollision :ArcadeBodyCollision

Whether this Body is checked for collisions and for which directions. You can set checkCollision.none = true to disable collision checks.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 659)

collideWorldBounds :boolean

Whether this Body interacts with the world boundary.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 649)

customSeparateX :boolean

A flag disabling the default horizontal separation of colliding bodies. Pass your own collideCallback to the collider.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 587)

customSeparateY :boolean

A flag disabling the default vertical separation of colliding bodies. Pass your own collideCallback to the collider.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 598)

debugBodyColor :integer

The color of this Body on the debug display.

Type:
  • integer
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 111)

debugShowBody :boolean

Whether the Body's boundary is drawn to the debug display.

Type:
  • boolean
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 93)

debugShowVelocity :boolean

Whether the Body's velocity is drawn to the debug display.

Type:
  • boolean
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 102)

deltaMax :Phaser.Math.Vector2

The Body's absolute maximum change in position, in pixels per step.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 308)

drag :Phaser.Math.Vector2|number

Absolute loss of velocity due to movement, in pixels per second squared. The x and y components are applied separately.

When useDamping is true, this is 1 minus the damping factor. A value of 1 means the Body loses no velocity. A value of 0.95 means the Body loses 5% of its velocity per step. A value of 0.5 means the Body loses 50% of its velocity per step.

Drag is applied only when acceleration is zero.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 336)

embedded :boolean

Whether this Body is overlapped with another and both are not moving.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 639)

enable :boolean

Whether this Body is updated by the physics simulation.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 120)

facing :integer

The direction of the Body's velocity, as calculated during the last step. If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only.

Type:
  • integer
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 557)

friction :Phaser.Math.Vector2

If this Body is immovable and in motion, friction is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. The horizontal component (x) is applied only when two colliding Bodies are separated vertically. The vertical component (y) is applied only when two colliding Bodies are separated horizontally.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 454)

gameObject :Phaser.GameObjects.GameObject

The Game Object this Body belongs to.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 67)

gravity :Phaser.Math.Vector2

Acceleration due to gravity (specific to this Body), in pixels per second squared. Total gravity is the sum of this vector and the simulation's gravity.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 365)
See:

halfHeight :number

Half the Body's height, in pixels.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 270)

halfWidth :number

Half the Body's width, in pixels.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 261)

height :number

The height of the Body's boundary, in pixels. If the Body is circular, this is also the Body's diameter.

Type:
  • number
Since: 3.0.0
Default Value:
  • 64
Source: src/physics/arcade/Body.js (Line 222)

immovable :boolean

Whether this Body can be moved by collisions with another Body.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 567)

isCircle :boolean

Whether this Body's boundary is circular (true) or rectangular (false).

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 130)
See:

isMoving :boolean

Whether this Body is being moved by the moveTo or moveFrom methods.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 707)

<readonly> left :number

The left edge of the Body's boundary. Identical to x.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2055)

mass :number

The Body's inertia, relative to a default unit (1). With bounce, this affects the exchange of momentum (velocities) during collisions.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/physics/arcade/Body.js (Line 526)

maxAngular :number

The Body's maximum angular velocity, in degrees per second.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1000
Source: src/physics/arcade/Body.js (Line 516)

maxSpeed :number

The maximum speed this Body is allowed to reach.

If not negative it limits the scalar value of speed.

Any negative value means no maximum is being applied.

Type:
  • number
Since: 3.16.0
Source: src/physics/arcade/Body.js (Line 441)

maxVelocity :Phaser.Math.Vector2

The Body's absolute maximum velocity, in pixels per second. The horizontal and vertical components are applied separately.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 431)

moves :boolean

Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 577)

<readonly> newVelocity :Phaser.Math.Vector2

The Body's calculated velocity, in pixels per second, at the last step.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 298)

offset :Phaser.Math.Vector2

The offset of this Body's position from its Game Object's position, in source pixels.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 153)
See:

onCollide :boolean

Whether the simulation emits a collide event when this Body collides with another.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 409)
See:
  • Phaser.Physics.Arcade.World#collideEvent

onOverlap :boolean

Whether the simulation emits an overlap event when this Body overlaps with another.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 420)
See:
  • Phaser.Physics.Arcade.World#overlapEvent

onWorldBounds :boolean

Whether the simulation emits a worldbounds event when this Body collides with the world boundary (and collideWorldBounds is also true).

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 398)
See:
  • Phaser.Physics.Arcade.World#worldboundsEvent

overlapR :number

The amount of overlap (before separation), if this Body is circular and colliding with another circular body.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 629)

overlapX :number

The amount of horizontal overlap (before separation), if this Body is colliding with another.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 609)

overlapY :number

The amount of vertical overlap (before separation), if this Body is colliding with another.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 619)

<readonly> physicsType :integer

The Body's physics type (dynamic or static).

Type:
  • integer
Since: 3.0.0
Default Value:
  • Phaser.Physics.Arcade.DYNAMIC_BODY
Source: src/physics/arcade/Body.js (Line 729)

position :Phaser.Math.Vector2

The position of this Body within the simulation.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 163)

preRotation :number

The Body's rotation, in degrees, during the previous step.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 202)

prev :Phaser.Math.Vector2

The position of this Body during the previous step.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 172)

radius :number

If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. The true radius is equal to halfWidth.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 141)
See:

The right edge of the Body's boundary.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2072)

rotation :number

This body's rotation, in degrees, based on its angular acceleration and angular velocity. The Body's rotation controls the angle of its Game Object. It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 191)

sourceHeight :number

The unscaled height of the Body, in source pixels, as set by setSize(). The default is the height of the Body's Game Object's texture frame.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 244)
See:

sourceWidth :number

The unscaled width of the Body, in source pixels, as set by setSize(). The default is the width of the Body's Game Object's texture frame.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 233)
See:

speed :number

The calculated magnitude of the Body's velocity, in pixels per second, during the last step.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/arcade/Body.js (Line 547)

stopVelocityOnCollide :boolean

Whether this Body's movement by moveTo or moveFrom will be stopped by collisions with other bodies.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Body.js (Line 717)

syncBounds :boolean

Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 696)
See:

<readonly> top :number

The top edge of the Body's boundary. Identical to y.

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2089)

touching :ArcadeBodyCollision

Whether this Body is colliding with another and in which direction.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 669)

transform :object

Transformations applied to this Body.

Type:
  • object
Since: 3.4.0
Source: src/physics/arcade/Body.js (Line 76)

useDamping :boolean

If this Body is using drag for deceleration this property controls how the drag is applied. If set to true drag will use a damping effect rather than a linear approach. If you are creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in the game Asteroids) then you will get a far smoother and more visually correct deceleration by using damping, avoiding the axis-drift that is prone with linear deceleration.

If you enable this property then you should use far smaller drag values than with linear, as they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately.

Type:
  • boolean
Since: 3.10.0
Default Value:
  • false
Source: src/physics/arcade/Body.js (Line 466)

velocity :Phaser.Math.Vector2

The Body's velocity, in pixels per second.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 289)

wasTouching :ArcadeBodyCollision

Whether this Body was colliding with another during the last step, and in which direction.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 678)

width :number

The width of the Body's boundary, in pixels. If the Body is circular, this is also the Body's diameter.

Type:
  • number
Since: 3.0.0
Default Value:
  • 64
Source: src/physics/arcade/Body.js (Line 211)

world :Phaser.Physics.Arcade.World

The Arcade Physics simulation this Body belongs to.

Type:
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 58)

<nullable> worldBounce :Phaser.Math.Vector2

Rebound following a collision with the world boundary, relative to 1. If null, bounce is used instead.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/physics/arcade/Body.js (Line 385)

x :number

The Body's horizontal position (left edge).

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2013)

y :number

The Body's vertical position (top edge).

Type:
  • number
Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 2034)

Methods


checkWorldBounds()

Checks for collisions between this Body and the world boundary and separates them.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1043)
Returns:

True if this Body is colliding with the world boundary.

Type
boolean

deltaAbsX()

The absolute (non-negative) change in this Body's horizontal position from the previous step.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1337)
Returns:

The delta value.

Type
number

deltaAbsY()

The absolute (non-negative) change in this Body's vertical position from the previous step.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1350)
Returns:

The delta value.

Type
number

deltaX()

The change in this Body's horizontal position from the previous step. This value is set during the Body's update phase.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1363)
Returns:

The delta value.

Type
number

deltaY()

The change in this Body's vertical position from the previous step. This value is set during the Body's update phase.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1377)
Returns:

The delta value.

Type
number

deltaZ()

The change in this Body's rotation from the previous step, in degrees.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1391)
Returns:

The delta value.

Type
number

destroy()

Disables this Body and marks it for deletion by the simulation.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1404)

drawDebug(graphic)

Draws this Body's boundary and velocity, if enabled.

Parameters:
Name Type Description
graphic Phaser.GameObjects.Graphics

The Graphics object to draw on.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1420)

getBounds(obj)

Copies the coordinates of this Body's edges into an object.

Parameters:
Name Type Description
obj ArcadeBodyBounds

An object to copy the values into.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1259)
Returns:
  • An object with {x, y, right, bottom}.
Type
ArcadeBodyBounds

hitTest(x, y)

Tests if the coordinates are within this Body's boundary.

Parameters:
Name Type Description
x number

The horizontal coordinate.

y number

The vertical coordinate.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1279)
Returns:

True if (x, y) is within this Body.

Type
boolean

onCeiling()

Whether this Body is touching a tile or the world boundary while moving up.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1309)
See:
Returns:

True if touching.

Type
boolean

onFloor()

Whether this Body is touching a tile or the world boundary while moving down.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1295)
See:
Returns:

True if touching.

Type
boolean

onWall()

Whether this Body is touching a tile or the world boundary while moving left or right.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1323)
See:
Returns:

True if touching.

Type
boolean

postUpdate(resetDelta)

Feeds the Body results back into the parent Game Object.

Parameters:
Name Type Description
resetDelta boolean

Reset the delta properties?

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 971)

reset(x, y)

Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. If the Body had any velocity or acceleration it is lost as a result of calling this.

Parameters:
Name Type Description
x number

The horizontal position to place the Game Object and Body.

y number

The vertical position to place the Game Object and Body.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1211)

setAcceleration(x, y)

Sets the Body's acceleration.

Parameters:
Name Type Description
x number

The horizontal component, in pixels per second squared.

y number

The vertical component, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1639)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAccelerationX(value)

Sets the Body's horizontal acceleration.

Parameters:
Name Type Description
value number

The acceleration, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1657)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAccelerationY(value)

Sets the Body's vertical acceleration.

Parameters:
Name Type Description
value number

The acceleration, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1674)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAllowDrag( [value])

Enables or disables drag.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

true to allow drag on this body, or false to disable it.

Since: 3.9.0
Source: src/physics/arcade/Body.js (Line 1691)
See:
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAllowGravity( [value])

Enables or disables gravity's effect on this Body.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

true to allow gravity on this body, or false to disable it.

Since: 3.9.0
Source: src/physics/arcade/Body.js (Line 1711)
See:
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAllowRotation( [value])

Enables or disables rotation.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

true to allow rotation on this body, or false to disable it.

Since: 3.9.0
Source: src/physics/arcade/Body.js (Line 1731)
See:
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAngularAcceleration(value)

Sets the Body's angular acceleration.

Parameters:
Name Type Description
value number

The acceleration, in degrees per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1924)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAngularDrag(value)

Sets the Body's angular drag.

Parameters:
Name Type Description
value number

The drag, in degrees per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1941)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setAngularVelocity(value)

Sets the Body's angular velocity.

Parameters:
Name Type Description
value number

The velocity, in degrees per second.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1907)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setBounce(x, y)

Sets the Body's bounce.

Parameters:
Name Type Description
x number

The horizontal bounce, relative to 1.

y number

The vertical bounce, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1587)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setBounceX(value)

Sets the Body's horizontal bounce.

Parameters:
Name Type Description
value number

The bounce, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1605)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setBounceY(value)

Sets the Body's vertical bounce.

Parameters:
Name Type Description
value number

The bounce, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1622)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setCircle(radius [, offsetX] [, offsetY])

Sizes and positions this Body's boundary, as a circle.

Parameters:
Name Type Argument Description
radius number

The radius of the Body, in source pixels.

offsetX number <optional>

The horizontal offset of the Body from its Game Object, in source pixels.

offsetY number <optional>

The vertical offset of the Body from its Game Object, in source pixels.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1168)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setCollideWorldBounds( [value])

Sets whether this Body collides with the world boundary.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

True (collisions) or false (no collisions).

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1469)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setDrag(x, y)

Sets the Body's drag.

Parameters:
Name Type Description
x number

The horizontal component, in pixels per second squared.

y number

The vertical component, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1751)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setDragX(value)

Sets the Body's horizontal drag.

Parameters:
Name Type Description
value number

The drag, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1769)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setDragY(value)

Sets the Body's vertical drag.

Parameters:
Name Type Description
value number

The drag, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1786)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setEnable( [value])

Sets the Body's enable property.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

The value to assign to enable.

Since: 3.15.0
Source: src/physics/arcade/Body.js (Line 1994)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setFriction(x, y)

Sets the Body's friction.

Parameters:
Name Type Description
x number

The horizontal component, relative to 1.

y number

The vertical component, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1855)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setFrictionX(value)

Sets the Body's horizontal friction.

Parameters:
Name Type Description
value number

The friction value, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1873)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setFrictionY(value)

Sets the Body's vertical friction.

Parameters:
Name Type Description
value number

The friction value, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1890)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setGravity(x, y)

Sets the Body's gravity.

Parameters:
Name Type Description
x number

The horizontal component, in pixels per second squared.

y number

The vertical component, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1803)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setGravityX(value)

Sets the Body's horizontal gravity.

Parameters:
Name Type Description
value number

The gravity, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1821)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setGravityY(value)

Sets the Body's vertical gravity.

Parameters:
Name Type Description
value number

The gravity, in pixels per second squared.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1838)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setImmovable( [value])

Sets the Body's immovable property.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

The value to assign to immovable.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1975)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setMass(value)

Sets the Body's mass.

Parameters:
Name Type Description
value number

The mass value, relative to 1.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1958)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setMaxSpeed(value)

Sets the maximum speed the Body can move.

Parameters:
Name Type Description
value number

The maximum speed value, in pixels per second. Set to a negative value to disable.

Since: 3.16.0
Source: src/physics/arcade/Body.js (Line 1570)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setMaxVelocity(x [, y])

Sets the Body's maximum velocity.

Parameters:
Name Type Argument Default Description
x number

The horizontal velocity, in pixels per second.

y number <optional>
x

The vertical velocity, in pixels per second.

Since: 3.10.0
Source: src/physics/arcade/Body.js (Line 1552)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setOffset(x [, y])

Sets the offset of the Body's position from its Game Object's position.

Parameters:
Name Type Argument Default Description
x number

The horizontal offset, in source pixels.

y number <optional>
x

The vertical offset, in source pixels.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1093)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setSize( [width] [, height] [, center])

Sizes and positions this Body's boundary, as a rectangle. Modifies the Body offset if center is true (the default). Resets the width and height to match current frame, if no width and height provided and a frame is found.

Parameters:
Name Type Argument Default Description
width integer <optional>

The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width.

height integer <optional>

The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height.

center boolean <optional>
true

Modify the Body's offset, placing the Body's center on its Game Object's center. Only works if the Game Object has the getCenter method.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1113)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setVelocity(x [, y])

Sets the Body's velocity.

Parameters:
Name Type Argument Default Description
x number

The horizontal velocity, in pixels per second.

y number <optional>
x

The vertical velocity, in pixels per second.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1488)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setVelocityX(value)

Sets the Body's horizontal velocity.

Parameters:
Name Type Description
value number

The velocity, in pixels per second.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1508)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

setVelocityY(value)

Sets the Body's vertical velocity.

Parameters:
Name Type Description
value number

The velocity, in pixels per second.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1530)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

stop()

Sets acceleration, velocity, and speed to zero.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1240)
Returns:

This Body object.

Type
Phaser.Physics.Arcade.Body

update(delta)

Updates the Body.

Parameters:
Name Type Description
delta number

The delta time, in seconds, elapsed since the last frame.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 886)
Fires:
  • Phaser.Physics.Arcade.World#event:worldbounds

updateBounds()

Updates the Body's transform, width, height, and center from its Game Object. The Body's position isn't changed.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 804)

updateCenter()

Updates the Body's center from its position, width, and height.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 875)

willDrawDebug()

Whether this Body will be drawn to the debug display.

Since: 3.0.0
Source: src/physics/arcade/Body.js (Line 1456)
Returns:

True if either debugShowBody or debugShowVelocity are enabled.

Type
boolean