Class: Collider

Phaser.Physics.Arcade. Collider

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.


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 overlap.

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 ArcadePhysicsCallback

The callback to invoke when the two objects collide.

processCallback 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
Source: src/physics/arcade/Collider.js (Line 9)

Members


active :boolean

Whether the collider is active.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/arcade/Collider.js (Line 51)

callbackContext :object

The context the collideCallback and processCallback will run in.

Type:
  • object
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 106)

collideCallback :ArcadePhysicsCallback

The callback to invoke when the two objects collide.

Type:
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 88)

name :string

The name of the collider (unused by Phaser).

Type:
  • string
Since: 3.1.0
Source: src/physics/arcade/Collider.js (Line 42)

object1 :Phaser.Types.Physics.Arcade.ArcadeColliderType

The first object to check for collision.

Type:
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 70)

object2 :Phaser.Types.Physics.Arcade.ArcadeColliderType

The second object to check for collision.

Type:
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 79)

overlapOnly :boolean

Whether to check for collisions or overlaps.

Type:
  • boolean
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 61)

processCallback :ArcadePhysicsCallback

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

Type:
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 97)

world :Phaser.Physics.Arcade.World

The world in which the bodies will collide.

Type:
Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 33)

Methods


destroy()

Removes Collider from World and disposes of its resources.

Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 153)

setName(name)

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.

Since: 3.1.0
Source: src/physics/arcade/Collider.js (Line 116)
Returns:

This Collider instance.

Type
Phaser.Physics.Arcade.Collider

update()

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

Since: 3.0.0
Source: src/physics/arcade/Collider.js (Line 135)