Phaser API Documentation

  Version: 
Filter

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.

Constructor:

new Collider(world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext)

Parameters:

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.

Since: 3.0.0

Members

active: boolean
Focus
Focus

Description:

Whether the collider is active.

Type:
boolean
Default: true
Since: 3.0.0
Focus
Focus
callbackContext: object
Focus
Focus

Description:

The context the collideCallback and processCallback will run in.

Type:
object
Since: 3.0.0
Focus
Focus

Description:

The callback to invoke when the two objects collide.

Type:
Since: 3.0.0
Focus
Focus
name: string
Focus
Focus

Description:

The name of the collider (unused by Phaser).

Type:
string
Since: 3.1.0
Focus
Focus

Description:

The first object to check for collision.

Type:
Since: 3.0.0
Focus
Focus

Description:

The second object to check for collision.

Type:
Since: 3.0.0
Focus
Focus
overlapOnly: boolean
Focus
Focus

Description:

Whether to check for collisions or overlaps.

Type:
boolean
Since: 3.0.0
Focus
Focus

Description:

If a processCallback exists it must return true or collision checking will be skipped.

Type:
Since: 3.0.0
Focus
Focus

Description:

The world in which the bodies will collide.

Type:
Since: 3.0.0
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Removes Collider from World and disposes of its resources.

Since: 3.0.0
Focus
Focus
setName(name)
Focus
Focus

Description:

A name for the Collider.

Phaser does not use this value, it's for your own reference.

Parameters:

name type description
name string

The name to assign to the Collider.

Returns:
Description:

This Collider instance.

Since: 3.1.0
Focus
Focus
update()
Focus
Focus

Description:

Called by World as part of its step processing, initial operation of collision checking.

Since: 3.0.0
Focus
Focus