new StaticBody(world, gameObject)
Parameters:
Name | Type | Description |
---|---|---|
world |
Phaser.Physics.Arcade.World | The Arcade Physics simulation this Static Body belongs to. |
gameObject |
Phaser.GameObjects.GameObject | The Game Object this Static Body belongs to. |
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 13)
Members
-
<readonly> allowGravity :boolean
-
A constant
false
value expected by the Arcade Physics simulation.Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 189)
-
blocked :Phaser.Types.Physics.Arcade.ArcadeBodyCollision
-
This property is kept for compatibility with Dynamic Bodies. Avoid using it.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 395)
-
<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 987)
-
<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 210)
-
center :Phaser.Math.Vector2
-
The center of the Static Body's boundary. This is the midpoint of its
position
(top-left corner) and its bottom-right corner.Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 169)
-
checkCollision :Phaser.Types.Physics.Arcade.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 365)
-
<readonly> collideWorldBounds :boolean
-
Whether this StaticBody interacts with the world boundary. Always false for a Static Body. (Static Bodies never collide with the world boundary.)
Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 353)
-
customSeparateX :boolean
-
A flag disabling the default horizontal separation of colliding bodies. Pass your own
collideHandler
to the collider.Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 293)
-
customSeparateY :boolean
-
A flag disabling the default vertical separation of colliding bodies. Pass your own
collideHandler
to the collider.Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 303)
-
debugBodyColor :number
-
The color of this Static Body on the debug display.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 68)
-
debugShowBody :boolean
-
Whether the Static Body's boundary is drawn to the debug display.
Type:
- boolean
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 59)
-
embedded :boolean
-
Whether this StaticBody has ever overlapped with another while both were not moving.
Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 343)
-
enable :boolean
-
Whether this Static Body is updated by the physics simulation.
Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- true
- Source: src/physics/arcade/StaticBody.js (Line 77)
-
gameObject :Phaser.GameObjects.GameObject
-
The Game Object this Static Body belongs to.
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 200)
-
halfHeight :number
-
Half the Static Body's height, in pixels. If the Static Body is circular, this is also the Static Body's radius.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 159)
-
halfWidth :number
-
Half the Static Body's width, in pixels. If the Static Body is circular, this is also the Static Body's radius.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 149)
-
height :number
-
The height of the Static Body's boundary, in pixels. If the Static Body is circular, this is also the Static Body's diameter.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 139)
-
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 264)
-
isCircle :boolean
-
Whether this Static Body's boundary is circular (
true
) or rectangular (false
).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 936)
-
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 254)
-
<readonly> offset :Phaser.Math.Vector2
-
The offset set by Phaser.Physics.Arcade.StaticBody#setCircle or Phaser.Physics.Arcade.StaticBody#setSize.
This doesn't affect the Static Body's position, because a Static Body does not follow its Game Object.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 108)
-
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 234)
-
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 244)
-
<readonly> onWorldBounds :boolean
-
Whether the simulation emits a
worldbounds
event when this StaticBody collides with the world boundary. Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger aworldbounds
event.)Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 222)
-
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 333)
-
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 313)
-
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 323)
-
physicsType :number
-
The StaticBody's physics type (static by default).
Type:
- number
- Since: 3.0.0
- Default Value:
-
- Phaser.Physics.Arcade.STATIC_BODY
- Source: src/physics/arcade/StaticBody.js (Line 405)
-
position :Phaser.Math.Vector2
-
The position of this Static Body within the simulation.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 120)
-
pushable :boolean
-
Sets if this Body can be pushed by another Body.
A body that cannot be pushed will reflect back all of the velocity it is given to the colliding body. If that body is also not pushable, then the separation will be split between them evenly.
If you want your body to never move or seperate at all, see the
setImmovable
method.By default, Static Bodies are not pushable.
Type:
- boolean
- Since: 3.50.0
- Default Value:
-
- false
- Source: src/physics/arcade/StaticBody.js (Line 274)
- See:
-
- Phaser.GameObjects.Components.Pushable#setPushable
-
radius :number
-
If this Static Body is circular, this is the radius of the boundary, as set by Phaser.Physics.Arcade.StaticBody#setCircle, in pixels. Equal to
halfWidth
.Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/physics/arcade/StaticBody.js (Line 97)
-
<readonly> right :number
-
The right-most x coordinate of the area of the StaticBody.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 953)
-
<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 970)
-
touching :Phaser.Types.Physics.Arcade.ArcadeBodyCollision
-
This property is kept for compatibility with Dynamic Bodies. Avoid using it.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 374)
-
<readonly> velocity :Phaser.Math.Vector2
-
A constant zero velocity used by the Arcade Physics simulation for calculations.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 179)
-
wasTouching :Phaser.Types.Physics.Arcade.ArcadeBodyCollision
-
This property is kept for compatibility with Dynamic Bodies. Avoid using it. The values are always false for a Static Body.
Type:
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 384)
-
width :number
-
The width of the Static Body's boundary, in pixels. If the Static Body is circular, this is also the Static Body's diameter.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 129)
-
world :Phaser.Physics.Arcade.World
-
The Arcade Physics simulation this Static Body belongs to.
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 886)
-
y :number
-
The y coordinate of the StaticBody.
Type:
- number
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 911)
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 741)
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 754)
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 767)
Returns:
The change in this StaticBody's velocity from the previous step. Always zero.
- 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 780)
Returns:
The change in this StaticBody's velocity from the previous step. Always zero.
- Type
- number
-
deltaZ()
-
The change in this StaticBody's rotation from the previous step. Always zero.
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 793)
Returns:
The change in this StaticBody's rotation from the previous step. Always zero.
- 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 806)
-
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 819)
-
getBounds(obj)
-
Returns the x and y coordinates of the top left and bottom right points of the StaticBody.
Parameters:
Name Type Description obj
Phaser.Types.Physics.Arcade.ArcadeBodyBounds The object which will hold the coordinates of the bounds.
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 695)
Returns:
The same object that was passed with
x
,y
,right
andbottom
values matching the respective values of the StaticBody. -
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 715)
Returns:
true
if the given coordinate lies within this body, otherwisefalse
.- Type
- boolean
-
postUpdate()
-
NOOP
- Since: 3.12.0
- Source: src/physics/arcade/StaticBody.js (Line 731)
-
reset( [x] [, y])
-
Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates.
Parameters:
Name Type Argument Description x
number <optional>
The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate.
y
number <optional>
The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate.
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 655)
-
setCircle(radius [, offsetX] [, offsetY])
-
Sets this Static Body to have a circular body and sets its size 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 599)
Returns:
This Static Body object.
-
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 440)
- See:
Returns:
This Static Body object.
-
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 863)
Returns:
This Static Body object.
-
setOffset(x, y)
-
Positions the Static Body at an offset from its Game Object.
Parameters:
Name Type Description x
number The horizontal offset of the Static Body from the Game Object's
x
.y
number The vertical offset of the Static Body from the Game Object's
y
.- Since: 3.4.0
- Source: src/physics/arcade/StaticBody.js (Line 505)
Returns:
This Static Body object.
-
setSize( [width] [, height] [, center])
-
Sets the size of the Static Body. When
center
is true, also repositions it. 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
number <optional>
The width of the Static Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width.
height
number <optional>
The height of the Static 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 Place the Static 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/StaticBody.js (Line 537)
Returns:
This Static Body object.
-
stop()
-
NOOP function. A Static Body cannot be stopped.
- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 682)
Returns:
This Static Body object.
-
updateCenter()
-
Updates the StaticBody's
center
from itsposition
and dimensions.- Since: 3.0.0
- Source: src/physics/arcade/StaticBody.js (Line 644)
-
updateFromGameObject()
-
Syncs the Static Body's position and size with its parent Game Object.
- Since: 3.1.0
- Source: src/physics/arcade/StaticBody.js (Line 476)
Returns:
This Static Body object.
-
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 850)
Returns:
Whether or not the StaticBody is going to show the debug visualization during postUpdate.
- Type
- boolean