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
-
- Source:
Properties:
Name Type Description accelerationPhaser.Point The velocity in pixels per second sq. of the Body.
-
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.
- Source:
Properties:
Name Type Description allowCollisionobject An object containing allowed collision.
-
allowGravity
-
- Default Value:
- true
- Source:
Properties:
Name Type Description allowGravityboolean Allow this Body to be influenced by the global Gravity?
-
allowRotation
-
- Default Value:
- true
- Source:
Properties:
Name Type Description allowRotationboolean Allow this Body to be rotated? (via angularVelocity, etc)
-
angularAcceleration
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description angularAccelerationnumber The angular acceleration in pixels per second sq. of the Body.
-
angularDrag
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description angularDragnumber The angular drag applied to the rotation of the Body.
-
angularVelocity
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description angularVelocitynumber The angular velocity in pixels per second sq. of the Body.
-
bottom
-
- Source:
Properties:
Name Type Description bottomnumber The bottom value of this Body (same as Body.y + Body.height)
-
bounce
-
- Source:
Properties:
Name Type Description bouncePhaser.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
-
- Source:
Properties:
Name Type Description centerPhaser.Point The center coordinate of the Physics Body.
-
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.
- Source:
Properties:
Name Type Description collideWorldBoundsboolean Should the Body collide with the World bounds?
-
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.
- Default Value:
- false
- Source:
Properties:
Name Type Description customSeparateXboolean Use a custom separation system or the built-in one?
-
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.
- Default Value:
- false
- Source:
Properties:
Name Type Description customSeparateYboolean Use a custom separation system or the built-in one?
-
drag
-
- Source:
Properties:
Name Type Description dragPhaser.Point The drag applied to the motion of the Body.
-
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.
- Source:
Properties:
Name Type Description embeddedboolean Body embed value.
-
facing
-
- Source:
Properties:
Name Type Description facingnumber A const reference to the direction the Body is traveling or facing.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game Local reference to game.
-
gravity
-
- Source:
Properties:
Name Type Description gravityPhaser.Point A private Gravity setting for the Body.
-
halfHeight
-
- Source:
Properties:
Name Type Description halfHeightnumber The calculated height / 2 of the physics body.
-
halfWidth
-
- Source:
Properties:
Name Type Description halfWidthnumber The calculated width / 2 of the physics body.
-
height
-
- Source:
Properties:
Name Type Description .numInternalID cache
-
hullX
-
- Source:
Properties:
Name Type Description hullXPhaser.Rectangle The dynamically calculated hull used during collision.
-
hullY
-
- Source:
Properties:
Name Type Description hullYPhaser.Rectangle The dynamically calculated hull used during collision.
-
immovable
-
- Default Value:
- false
- Source:
Properties:
Name Type Description immovableboolean An immovable Body will not receive any impacts from other bodies.
-
mass
-
- Default Value:
- 1
- Source:
Properties:
Name Type Description massnumber The mass of the Body.
-
maxAngular
-
- Default Value:
- 1000
- Source:
Properties:
Name Type Description maxAngularnumber The maximum angular velocity in pixels per second sq. that the Body can reach.
-
maxVelocity
-
- Source:
Properties:
Name Type Description maxVelocityPhaser.Point The maximum velocity in pixels per second sq. that the Body can reach.
-
moves
-
- Default Value:
- true
- Source:
Properties:
Name Type Description movesboolean Set to true to allow the Physics system to move this Body, other false to move it manually.
-
offset
-
- Source:
Properties:
Name Type Description offsetPhaser.Point The offset of the Physics Body from the Sprite x/y position.
-
overlapX
-
When this body collides with another, the amount of overlap is stored here.
- Source:
Properties:
Name Type Description overlapXnumber The amount of horizontal overlap during the collision.
-
overlapY
-
When this body collides with another, the amount of overlap is stored here.
- Source:
Properties:
Name Type Description overlapYnumber The amount of vertical overlap during the collision.
-
<readonly> preRotation
-
- Source:
Properties:
Name Type Description preRotationnumber The previous rotation of the physics body.
-
<readonly> preX
-
- Source:
Properties:
Name Type Description preXnumber The previous x position of the physics body.
-
<readonly> preY
-
- Source:
Properties:
Name Type Description preYnumber The previous y position of the physics body.
-
<protected> quadTreeIDs
-
- Source:
Properties:
Name Type Description quadTreeIDsArray Internal ID cache.
-
<protected> quadTreeIndex
-
- Source:
Properties:
Name Type Description quadTreeIndexnumber Internal ID cache.
-
right
-
- Source:
Properties:
Name Type Description rightnumber The right value of this Body (same as Body.x + Body.width)
-
rotation
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description rotationnumber The amount the Body is rotated.
-
<readonly> screenX
-
- Source:
Properties:
Name Type Description screenXnumber The x position of the physics body translated to screen space.
-
<readonly> screenY
-
- Source:
Properties:
Name Type Description screenYnumber The y position of the physics body translated to screen space.
-
skipQuadTree
-
- Default Value:
- false
- Source:
Properties:
Name Type Description skipQuadTreeboolean If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree.
-
<readonly> sourceHeight
-
- Source:
Properties:
Name Type Description sourceHeightnumber The un-scaled original size.
-
<readonly> sourceWidth
-
- Source:
Properties:
Name Type Description sourceWidthnumber The un-scaled original size.
-
sprite
-
- Source:
Properties:
Name Type Description spritePhaser.Sprite Reference to the parent Sprite.
-
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.
- Source:
Properties:
Name Type Description touchingobject An object containing touching results.
-
velocity
-
- Source:
Properties:
Name Type Description velocityPhaser.Point The velocity in pixels per second sq. of the Body.
-
wasTouching
-
This object is populated with previous touching values from the bodies previous collision.
- Source:
Properties:
Name Type Description wasTouchingobject An object containing previous touching results.
-
width
-
- Source:
Properties:
Name Type Description widthnumber The calculated width of the physics body.
-
<readonly> x
-
- Source:
Properties:
Name Type Description xnumber The x position of the physics body.
-
<readonly> y
-
- Source:
Properties:
Name Type Description ynumber The y position of the physics body.
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