Class: StaticBody

Phaser.Physics.Arcade. StaticBody

A Static Arcade Physics Body.

A Static Body never moves, and isn't automatically synchronized with its parent Game Object.
That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually.

A Static Body can collide with other Bodies, but is never moved by collisions.

Its dynamic counterpart is Phaser.Physics.Arcade.Body.


new StaticBody(world, gameObject)

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

[description]

gameObject Phaser.GameObjects.GameObject

[description]

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 13)

Members


<readonly> allowGravity :boolean

[description]

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

blocked :ArcadeBodyCollision

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

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 360)

<readonly> bottom :number

The lowest y coordinate of the area of the StaticBody. (y + height)

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

<readonly> bounce :Phaser.Math.Vector2

Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body.

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 201)

center :Phaser.Math.Vector2

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 161)

checkCollision :ArcadeBodyCollision

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

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 333)

collideWorldBounds :boolean

Whether this StaticBody interacts with the world boundary.

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

customSeparateX :boolean

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

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

customSeparateY :boolean

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

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

debugBodyColor :integer

[description]

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

debugShowBody :boolean

[description]

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

embedded :boolean

Whether this StaticBody is overlapped with another and both have zero velocity.

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

enable :boolean

[description]

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

gameObject :Phaser.GameObjects.GameObject

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 50)

<readonly> gravity :Phaser.Math.Vector2

Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body.

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 191)

halfHeight :number

[description]

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

halfWidth :number

[description]

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

height :number

[description]

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

immovable :boolean

Whether this object can be moved by collisions with another body.

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

isCircle :boolean

[description]

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

<readonly> left :number

Returns the left-most x coordinate of the area of the StaticBody.

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

mass :number

The StaticBody'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/StaticBody.js (Line 243)

offset :Phaser.Math.Vector2

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 107)

onCollide :boolean

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

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

onOverlap :boolean

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

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

onWorldBounds :boolean

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

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

overlapR :number

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

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

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/StaticBody.js (Line 283)

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/StaticBody.js (Line 293)

physicsType :integer

The StaticBody's physics type (static by default).

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

position :Phaser.Math.Vector2

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 116)

radius :number

[description]

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

The right-most x coordinate of the area of the StaticBody.

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

<readonly> top :number

The highest y coordinate of the area of the StaticBody.

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

touching :ArcadeBodyCollision

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

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 342)

<readonly> velocity :Phaser.Math.Vector2

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 170)

wasTouching :ArcadeBodyCollision

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

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 351)

width :number

[description]

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

world :Phaser.Physics.Arcade.World

[description]

Type:
Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 41)

x :number

The x coordinate of the StaticBody.

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

y :number

The y coordinate of the StaticBody.

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

Methods


deltaAbsX()

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

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 693)
Returns:

Always zero for a Static Body.

Type
number

deltaAbsY()

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

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 706)
Returns:

Always zero for a Static Body.

Type
number

deltaX()

The change in this StaticBody's horizontal position from the previous step. Always zero.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 719)
Returns:

Always zero for a Static Body.

Type
number

deltaY()

The change in this StaticBody's vertical position from the previous step. Always zero.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 732)
Returns:

0

Type
number

deltaZ()

[description]

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 745)
Returns:

0

Type
number

destroy()

Disables this Body and marks it for destruction during the next step.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 758)

drawDebug(graphic)

Draws a graphical representation of the StaticBody for visual debugging purposes.

Parameters:
Name Type Description
graphic Phaser.GameObjects.Graphics

The Graphics object to use for the debug drawing of the StaticBody.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 771)

getBounds(obj)

Returns the x and y coordinates of the top left and bottom right points of the StaticBody.

Parameters:
Name Type Description
obj ArcadeBodyBounds

The object which will hold the coordinates of the bounds.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 647)
Returns:

The same object that was passed with x, y, right and bottom values matching the respective values of the StaticBody.

Type
ArcadeBodyBounds

hitTest(x, y)

Checks to see if a given x,y coordinate is colliding with this Static Body.

Parameters:
Name Type Description
x number

The x coordinate to check against this body.

y number

The y coordinate to check against this body.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 667)
Returns:

true if the given coordinate lies within this body, otherwise false.

Type
boolean

postUpdate()

NOOP

Since: 3.12.0
Source: src/physics/arcade/StaticBody.js (Line 683)

reset(x, y)

Updates this Static Body's position based on the current Game Object it is bound to.
Similar to updateFromGameObject, but doesn't modify the Body's dimensions.

Parameters:
Name Type Description
x number

The x coordinate to reset the body to.

y number

The y coordinate to reset the body to.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 608)

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

Sets this Static Body to have a circular body and sets its sizes and position.

Parameters:
Name Type Argument Description
radius number

The radius of the StaticBody, in pixels.

offsetX number <optional>

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

offsetY number <optional>

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

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 552)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

setGameObject(gameObject [, update])

Changes the Game Object this Body is bound to.
First it removes its reference from the old Game Object, then sets the new one.
You can optionally update the position and dimensions of this Body to reflect that of the new Game Object.

Parameters:
Name Type Argument Default Description
gameObject Phaser.GameObjects.GameObject

The new Game Object that will own this Body.

update boolean <optional>
true

Reposition and resize this Body to match the new Game Object?

Since: 3.1.0
Source: src/physics/arcade/StaticBody.js (Line 403)
See:
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

setMass(value)

Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero.

Parameters:
Name Type Description
value number

The value to set the Mass to. Values of zero or less are changed to 0.1.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 803)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

setOffset(x, y)

Sets the offset of the body.

Parameters:
Name Type Description
x number

The horizontal offset of the Body from the Game Object's center.

y number

The vertical offset of the Body from the Game Object's center.

Since: 3.4.0
Source: src/physics/arcade/StaticBody.js (Line 469)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

setSize( [width] [, height] [, offsetX] [, offsetY])

Sets the size of the body.
Resets the width and height to match current frame, if no width and height provided and a frame is found.

Parameters:
Name Type Argument 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.

offsetX number <optional>

The horizontal offset of the Body from the Game Object's center.

offsetY number <optional>

The vertical offset of the Body from the Game Object's center.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 501)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

stop()

NOOP function. A Static Body cannot be stopped.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 634)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

updateCenter()

Updates the StaticBody's center from its position and dimensions.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 597)

updateFromGameObject()

Updates this Static Body so that its position and dimensions are updated
based on the current Game Object it is bound to.

Since: 3.1.0
Source: src/physics/arcade/StaticBody.js (Line 439)
Returns:

This Static Body object.

Type
Phaser.Physics.Arcade.StaticBody

willDrawDebug()

Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate.

Since: 3.0.0
Source: src/physics/arcade/StaticBody.js (Line 790)
Returns:

Whether or not the StaticBody is going to show the debug visualization during postUpdate.

Type
boolean