Class: Arcade

.Isometric. Arcade

IsoArcade Physics Constructor

new Arcade(game)

IsoArcade Physics constructor.

Parameters:
Name Type Description
game Phaser.Game

reference to the current game instance.

Source:

Members

bounds

Properties:
Name Type Description
bounds Phaser.Plugin.Isometric.Cube

The bounds inside of which the physics world exists. Defaults to match the world bounds relatively closely given the isometric projection.

Source:

checkCollision

Set the checkCollision properties to control for which bounds collision is processed. For example checkCollision.down = false means Bodies cannot collide with the World.bounds.bottom.

Properties:
Name Type Description
checkCollision object

An object containing allowed collision flags.

Source:

forceXY

Properties:
Name Type Description
forceX boolean

If true World.separate will always separate on the X and Y axes before Z. Otherwise it will check gravity totals first.

Source:

game

Properties:
Name Type Description
game Phaser.Game

Local reference to game.

Source:

gravity

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

The World gravity setting. Defaults to x: 0, y: 0, z: 0 or no gravity.

Source:

maxLevels

Properties:
Name Type Description
maxLevels number

Used by the QuadTree/Octree to set the maximum number of iteration levels.

Source:

maxObjects

Properties:
Name Type Description
maxObjects number

Used by the QuadTree/Octree to set the maximum number of objects per quad.

Source:

octree

Properties:
Name Type Description
octree Phaser.Plugin.Isometric.Octree

The world Octree.

Source:

OVERLAP_BIAS

Properties:
Name Type Description
OVERLAP_BIAS number

A value added to the delta values during collision checks.

Source:

quadTree

Properties:
Name Type Description
quadTree Phaser.QuadTree

The world QuadTree.

Source:

skipTree

Properties:
Name Type Description
skipTree boolean

If true an Octree/QuadTree will never be used for any collision. Handy for tightly packed games. See also Body.skipTree.

Source:

useQuadTree

Properties:
Name Type Description
useQuadTree boolean

If true, the collision/overlap routines will use a QuadTree, which will ignore the z position of objects when determining potential collisions. This will be faster if you don't do a lot of stuff on the z-axis.

Source:

Methods

collide(object1, object2, collideCallback, processCallback, callbackContext) → {boolean}

Checks for collision between two game objects. You can perform IsoSprite vs. IsoSprite, IsoSprite vs. Group or Group vs. Group collisions. The second parameter can be an array of objects, of differing types. The objects are also automatically separated. If you don't require separation then use IsoArcade.overlap instead. An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. NOTE: This function is not recursive, and will not test against children of objects passed (i.e. Groups within Groups).

Parameters:
Name Type Argument Default Description
object1 Phaser.Plugin.Isometric.IsoSprite | Phaser.Group

The first object to check. Can be an instance of Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.

object2 Phaser.Plugin.Isometric.IsoSprite | Phaser.Group | array

The second object or array of objects to check. Can be Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.

collideCallback function <optional>
null

An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter.

processCallback function <optional>
null

A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.

callbackContext object <optional>

The context in which to run the callbacks.

Source:
Returns:

True if a collision occured otherwise false.

Type
boolean

computeVelocity(axis, body, velocity, acceleration, drag, max) → {number}

A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. Based on a function in Flixel by @ADAMATOMIC

Parameters:
Name Type Argument Default Description
axis number

0 for nothing, 1 for X-axis, 2 for Y-axis, 3 for vertical (Z-axis).

body Phaser.Plugin.Isometric.Body

The Body object to be updated.

velocity number

Any component of velocity (e.g. 20).

acceleration number

Rate at which the velocity is changing.

drag number

Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.

max number <optional>
10000

An absolute value cap for the velocity.

Source:
Returns:

The altered Velocity value.

Type
number

distanceToXY(displayObject, x, y) → {number}

Find the distance between a display object (like a Sprite) and the given x/y coordinates only (ignore z). The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()

Parameters:
Name Type Description
displayObject any

The Display Object to test from.

x number

The x coordinate to test to.

y number

The y coordinate to test to.

Source:
Returns:

The distance between the object and the x/y coordinates.

Type
number

distanceToXYZ(displayObjectBody, x, y, z) → {number}

Find the distance between a display object (like a Sprite) and the given x/y/z coordinates. The calculation is made from the display objects x/y/z coordinate. This may be the top-left if its anchor hasn't been changed. If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()

Parameters:
Name Type Description
displayObjectBody any

The Display Object to test from.

x number

The x coordinate to test to.

y number

The y coordinate to test to.

z number

The y coordinate to test to

Source:
Returns:

The distance between the object and the x/y coordinates.

Type
number

enable(object, children)

This will create an IsoArcade Physics body on the given game object or array of game objects. A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.

Parameters:
Name Type Argument Default Description
object object | array | Phaser.Group

The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a body property.

children boolean <optional>
true

Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go.

Source:

enableBody(object)

Creates an IsoArcade Physics body on the given game object. A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled.

Parameters:
Name Type Description
object object

The game object to create the physics body on. A body will only be created if this object has a null body property.

Source:

intersects(body1, body2) → {boolean}

Check for intersection against two bodies.

Parameters:
Name Type Description
body1 Phaser.Plugin.Isometric.Body

The Body object to check.

body2 Phaser.Plugin.Isometric.Body

The Body object to check.

Source:
Returns:

True if they intersect, otherwise false.

Type
boolean

overlap(object1, object2, overlapCallback, processCallback, callbackContext) → {boolean}

Checks for overlaps between two game objects. The objects can be IsoSprites or Groups. You can perform IsoSprite vs. IsoSprite, IsoSprite vs. Group and Group vs. Group overlap checks. Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. The second parameter can be an array of objects, of differing types. NOTE: This function is not recursive, and will not test against children of objects passed (i.e. Groups within Groups).

Parameters:
Name Type Argument Default Description
object1 Phaser.Plugin.Isometric.IsoSprite | Phaser.Group

The first object to check. Can be an instance of Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.

object2 Phaser.Plugin.Isometric.IsoSprite | Phaser.Group | array

The second object or array of objects to check. Can be Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.

overlapCallback function <optional>
null

An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them.

processCallback function <optional>
null

A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if processCallback returns true.

callbackContext object <optional>

The context in which to run the callbacks.

Source:
Returns:

True if an overlap occured otherwise false.

Type
boolean

setBounds(x, y, z, widthX, widthY, height)

Updates the size of this physics world.

Parameters:
Name Type Description
x number

Bottom rear most corner of the world.

y number

Bottom rear most corner of the world.

z number

Bottom rear most corner of the world.

widthX number

New X width (breadth) of the world. Can never be smaller than the Game.width.

widthY number

New Y width (depth) of the world. Can never be smaller than the Game.width.

height number

New height of the world. Can never be smaller than the Game.height.

Source:

setBoundsToWorld()

Updates the size of this physics world to match the size of the game world.

Source:

updateMotion(body)

Called automatically by a Physics body, it updates all motion related values on the Body.

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

The Body object to be updated.

Source: