new Arcade(game)
IsoArcade Physics constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
game |
Phaser.Game | reference to the current game instance. |
- Source:
Members
-
bounds
-
- Source:
Properties:
Name Type Description boundsPhaser.Plugin.Isometric.Cube The bounds inside of which the physics world exists. Defaults to match the world bounds relatively closely given the isometric projection.
-
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.
- Source:
Properties:
Name Type Description checkCollisionobject An object containing allowed collision flags.
-
forceXY
-
- Source:
Properties:
Name Type Description forceXboolean If true World.separate will always separate on the X and Y axes before Z. Otherwise it will check gravity totals first.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game Local reference to game.
-
gravity
-
- Source:
Properties:
Name Type Description gravityPhaser.Plugin.Isometric.Point3 The World gravity setting. Defaults to x: 0, y: 0, z: 0 or no gravity.
-
maxLevels
-
- Source:
Properties:
Name Type Description maxLevelsnumber Used by the QuadTree/Octree to set the maximum number of iteration levels.
-
maxObjects
-
- Source:
Properties:
Name Type Description maxObjectsnumber Used by the QuadTree/Octree to set the maximum number of objects per quad.
-
octree
-
- Source:
Properties:
Name Type Description octreePhaser.Plugin.Isometric.Octree The world Octree.
-
OVERLAP_BIAS
-
- Source:
Properties:
Name Type Description OVERLAP_BIASnumber A value added to the delta values during collision checks.
-
quadTree
-
- Source:
Properties:
Name Type Description quadTreePhaser.QuadTree The world QuadTree.
-
skipTree
-
- Source:
Properties:
Name Type Description skipTreeboolean If true an Octree/QuadTree will never be used for any collision. Handy for tightly packed games. See also Body.skipTree.
-
useQuadTree
-
- Source:
Properties:
Name Type Description useQuadTreeboolean 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.
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 object1Phaser.Plugin.Isometric.IsoSprite | Phaser.Group The first object to check. Can be an instance of Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.
object2Phaser.Plugin.Isometric.IsoSprite | Phaser.Group | array The second object or array of objects to check. Can be Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.
collideCallbackfunction <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.
processCallbackfunction <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.
callbackContextobject <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 axisnumber 0 for nothing, 1 for X-axis, 2 for Y-axis, 3 for vertical (Z-axis).
bodyPhaser.Plugin.Isometric.Body The Body object to be updated.
velocitynumber Any component of velocity (e.g. 20).
accelerationnumber Rate at which the velocity is changing.
dragnumber Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
maxnumber <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 displayObjectany The Display Object to test from.
xnumber The x coordinate to test to.
ynumber 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 displayObjectBodyany The Display Object to test from.
xnumber The x coordinate to test to.
ynumber The y coordinate to test to.
znumber 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 objectobject | 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
bodyproperty.childrenboolean <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 objectobject The game object to create the physics body on. A body will only be created if this object has a null
bodyproperty.- Source:
-
intersects(body1, body2) → {boolean}
-
Check for intersection against two bodies.
Parameters:
Name Type Description body1Phaser.Plugin.Isometric.Body The Body object to check.
body2Phaser.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 object1Phaser.Plugin.Isometric.IsoSprite | Phaser.Group The first object to check. Can be an instance of Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.
object2Phaser.Plugin.Isometric.IsoSprite | Phaser.Group | array The second object or array of objects to check. Can be Phaser.Plugin.Isometric.IsoSprite or Phaser.Group.
overlapCallbackfunction <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.
processCallbackfunction <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.
callbackContextobject <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 xnumber Bottom rear most corner of the world.
ynumber Bottom rear most corner of the world.
znumber Bottom rear most corner of the world.
widthXnumber New X width (breadth) of the world. Can never be smaller than the Game.width.
widthYnumber New Y width (depth) of the world. Can never be smaller than the Game.width.
heightnumber 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 bodyPhaser.Plugin.Isometric.Body The Body object to be updated.
- Source: