An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects every step. If a collision, or overlap, occurs it will invoke the given callbacks.
Note, if setting overlapOnly
to true
, and one of the objects is a TilemapLayer
, every tile in the layer, regardless of tile ID, will be checked for collision.
Even if the layer has had only a subset of tile IDs enabled for collision, all tiles will still be checked for overlap.
new Collider(world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext)
name | type | description |
---|---|---|
world | Phaser.Physics.Arcade.World |
The Arcade physics World that will manage the collisions. |
overlapOnly | boolean |
Whether to check for collisions or overlaps. |
object1 | Phaser.Types.Physics.Arcade.ArcadeColliderType |
The first object to check for collision. |
object2 | Phaser.Types.Physics.Arcade.ArcadeColliderType |
The second object to check for collision. |
collideCallback | Phaser.Types.Physics.Arcade.ArcadePhysicsCallback |
The callback to invoke when the two objects collide. |
processCallback | Phaser.Types.Physics.Arcade.ArcadePhysicsCallback |
The callback to invoke when the two objects collide. Must return a boolean. |
callbackContext | any |
The scope in which to call the callbacks. |
Whether the collider is active.
The context the collideCallback and processCallback will run in.
The callback to invoke when the two objects collide.
The name of the collider (unused by Phaser).
The first object to check for collision.
The second object to check for collision.
Whether to check for collisions or overlaps.
If a processCallback exists it must return true or collision checking will be skipped.
The world in which the bodies will collide.
Removes Collider from World and disposes of its resources.
A name for the Collider.
Phaser does not use this value, it's for your own reference.
name | type | description |
---|---|---|
name | string |
The name to assign to the Collider. |
This Collider instance.
Called by World as part of its step processing, initial operation of collision checking.