Class: Body

.Isometric. Body

The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.

new Body(sprite)

Parameters:
Name Type Description
sprite Phaser.Plugin.Isometric.IsoSprite

The IsoSprite object this physics body belongs to.

Source:

Members

acceleration

Properties:
Name Type Description
acceleration Phaser.Plugin.Isometric.Point3

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

Source:

allowGravity

Properties:
Name Type Description
allowGravity boolean

Allow this Body to be influenced by gravity? Either world or local.

Default Value:
  • true
Source:

allowRotation

Properties:
Name Type Description
allowRotation boolean

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

Default Value:
  • true
Source:

<readonly> angle

Properties:
Name Type Description
angle number

The angle of the Body in radians as calculated by its velocity, rather than its visual angle.

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:

blocked

This object is populated with boolean values when the Body collides with the World bounds or a Tile. For example if blocked.up is true then the Body cannot move up.

Properties:
Name Type Description
blocked object

An object containing on which faces this Body is blocked from moving, if any.

Source:

<readonly> bottom

Properties:
Name Type Description
right number

The front Y value of this Body (same as Body.y + Body.widthY) - alias used for QuadTree

Source:

bounce

Properties:
Name Type Description
bounce Phaser.Plugin.Isometric.Point3

The elasticitiy of the Body when colliding. bounce.x/y/z = 1 means full rebound, bounce.x/y/z = 0.5 means 50% rebound velocity.

Source:

center

Properties:
Name Type Description
center Phaser.Plugin.Isometric.Point3

The center coordinate of the physics body.

Source:

checkCollision

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

Properties:
Name Type Description
checkCollision object

An object containing allowed collision.

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.IsoArcade.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.IsoArcade.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:

customSeparateZ

This flag allows you to disable the custom z separation that takes place by Physics.IsoArcade.separate. Used in combination with your own collision processHandler you can create whatever type of collision response you need.

Properties:
Name Type Description
customSeparateZ boolean

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

Default Value:
  • false
Source:

deltaMax

Properties:
Name Type Description
deltaMax Phaser.Plugin.Isometric.Point3

The Sprite position is updated based on the delta x/y values. You can set a cap on those (both +-) using deltaMax.

Source:

drag

Properties:
Name Type Description
drag Phaser.Plugin.Isometric.Point3

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:

enable

Properties:
Name Type Description
enable boolean

A disabled body won't be checked for any form of collision or overlap or have its pre/post updates run.

Default Value:
  • true
Source:

facing

Properties:
Name Type Description
facing number

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

Source:

<readonly> frontX

Properties:
Name Type Description
right number

The front X value of this Body (same as Body.x + Body.widthX)

Source:

<readonly> frontY

Properties:
Name Type Description
right number

The front Y value of this Body (same as Body.y + Body.widthY)

Source:

game

Properties:
Name Type Description
game Phaser.Game

Local reference to game.

Source:

gravity

Properties:
Name Type Description
gravity Phaser.Plugin.Isometric.Point3

A local gravity applied to this Body. If non-zero this over rides any world gravity, unless Body.allowGravity is set to false.

Source:

halfHeight

Properties:
Name Type Description
halfHeight number

The calculated height / 2 of the physics body.

Source:

halfWidthX

Properties:
Name Type Description
halfWidthX number

The calculated X width / 2 of the physics body.

Source:

halfWidthY

Properties:
Name Type Description
halfWidthX number

The calculated X width / 2 of the physics body.

Source:

height

Properties:
Name Type Description
height number

The calculated height of the physics body.

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.Plugin.Isometric.Point3

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

Source:

moves

If you have a Body that is being moved around the world via a tween or a Group motion, but its local x/y position never actually changes, then you should set Body.moves = false. Otherwise it will most likely fly off the screen. If you want the physics system to move the body around, then set moves to true.

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:

<readonly> newVelocity

Properties:
Name Type Description
newVelocity Phaser.Plugin.Isometric.Point3

New velocity.

Source:

offset

Properties:
Name Type Description
offset Phaser.Point

The offset of the Physics Body from the IsoSprite x/y/z 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:

overlapZ

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:

phase

Properties:
Name Type Description
phase number

Is this Body in a preUpdate (1) or postUpdate (2) state?

Source:

<readonly> position

Properties:
Name Type Description
position Phaser.Plugin.Isometric.Point3

The position of the physics body.

Source:

<readonly> preRotation

Properties:
Name Type Description
preRotation number

The previous rotation of the physics body.

Source:

<readonly> prev

Properties:
Name Type Description
prev Phaser.Point

The previous position of the physics body.

Source:
Properties:
Name Type Description
right number

The front X value of this Body (same as Body.x + Body.widthX) - alias used for QuadTree

Source:

rotation

Properties:
Name Type Description
rotation number

The amount the Body is rotated.

Source:

skipTree

Properties:
Name Type Description
skipTree boolean

If true and you collide this IsoSprite against a Group, it will disable the collision check from using a QuadTree/Octree.

Source:

<readonly> sourceHeight

Properties:
Name Type Description
sourceHeight number

The un-scaled original size.

Source:

<readonly> sourceWidthX

Properties:
Name Type Description
sourceWidthX number

The un-scaled original size.

Source:

<readonly> sourceWidthY

Properties:
Name Type Description
sourceWidthY number

The un-scaled original size.

Source:

<readonly> speed

Properties:
Name Type Description
speed number

The speed of the Body as calculated by its velocity.

Source:

sprite

Properties:
Name Type Description
sprite Phaser.Plugin.Isometric.IsoSprite

Reference to the parent IsoSprite.

Source:

<readonly> top

Properties:
Name Type Description
bottom number

The top value of this Body (same as Body.z + Body.height)

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:

type

Properties:
Name Type Description
type number

The type of physics system this body belongs to.

Source:

velocity

Properties:
Name Type Description
velocity Phaser.Plugin.Isometric.Point3

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:

widthX

Properties:
Name Type Description
widthX number

The calculated X width (breadth) of the physics body.

Source:

widthY

Properties:
Name Type Description
widthY number

The calculated Y width (depth) of the physics body.

Source:

x

Properties:
Name Type Description
x number

The x position.

Source:

y

Properties:
Name Type Description
y number

The y position.

Source:

z

Properties:
Name Type Description
z number

The z position.

Source:

Methods

<protected> checkWorldBounds()

Internal method.

Source:

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

deltaAbsZ() → {number}

Returns the absolute delta z value.

Source:
Returns:

The absolute delta value.

Type
number

deltaR() → {number}

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

Source:
Returns:

The delta value. Positive if the motion was clockwise, negative if anti-clockwise.

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. Positive if the motion was to the right, negative if to the left.

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. Positive if the motion was downwards, negative if upwards.

Type
number

deltaZ() → {number}

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

Source:
Returns:

The delta value. Positive if the motion was downwards, negative if upwards.

Type
number

destroy()

Removes this body's reference to its parent sprite, freeing it up for gc.

Source:

getCorners() → {Array.<Phaser.Plugin.Isometric.Point3>}

Returns the 8 corners that make up the body's bounding cube.

Source:
Returns:

An array of Phaser.Plugin.Isometric.Point3 values specifying each corner co-ordinate.

Type
Array.<Phaser.Plugin.Isometric.Point3>

hitTest(x, y, z) → {boolean}

Tests if a world point lies within this Body.

Parameters:
Name Type Description
x number

The world x coordinate to test.

y number

The world y coordinate to test.

z number

The world z coordinate to test.

Source:
Returns:

True if the given coordinates are inside this Body, otherwise false.

Type
boolean

onFloor() → {boolean}

Returns true if the bottom of this Body is in contact with either the world bounds.

Source:
Returns:

True if in contact with either the world bounds.

Type
boolean

onWall() → {boolean}

Returns true if either side of this Body is in contact with either the world bounds.

Source:
Returns:

True if in contact with world bounds.

Type
boolean

<protected> postUpdate()

Internal method.

Source:

<protected> preUpdate()

Internal method.

Source:

render(context, body, color, filled)

Render IsoSprite Body.

Parameters:
Name Type Argument Default Description
context object

The context to render to.

body Phaser.Plugin.Isometric.Body

The Body to render the info of.

color string <optional>
'rgba(0,255,0,0.4)'

color of the debug info to be rendered. (format is css color string).

filled boolean <optional>
true

Render the objected as a filled (default, true) or a stroked (false)

Source:

renderBodyInfo(body, x, y, color)

Render IsoSprite Body Physics Data as text.

Parameters:
Name Type Argument Default Description
body Phaser.Plugin.Isometric.Body

The Body to render the info of.

x number

X position of the debug info to be rendered.

y number

Y position of the debug info to be rendered.

color string <optional>
'rgb(255,255,255)'

color of the debug info to be rendered. (format is css color string).

Source:

reset(x, y, z)

Resets all Body values (velocity, acceleration, rotation, etc)

Parameters:
Name Type Description
x number

The new x position of the Body.

y number

The new y position of the Body.

z number

The new z position of the Body.

Source:

setSize(widthX, widthY, height, offsetX, offsetY, offsetY)

You can modify the size of the physics Body to be any dimension you need. So it could be smaller or larger than the parent Sprite. You can also control the x, y and z offset, which is the position of the Body relative to the center of the Sprite.

Parameters:
Name Type Argument Description
widthX number

The X width (breadth) of the Body.

widthY number

The Y width (depth) of the Body.

height number

The height of the Body.

offsetX number <optional>

The X offset of the Body from the Sprite position.

offsetY number <optional>

The Y offset of the Body from the Sprite position.

offsetY number <optional>

The Z offset of the Body from the Sprite position.

Source:

<protected> updateBounds()

Internal method.

Source: