Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Physics . Arcade . Collider

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

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.

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

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
collideCallback: ArcadePhysicsCallback
Focus
Focus

Description:

The callback to invoke when the two objects collide.

Type:
ArcadePhysicsCallback
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
processCallback: ArcadePhysicsCallback
Focus
Focus

Description:

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

Type:
ArcadePhysicsCallback
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.

Examples:
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.

Examples:
Since: 3.1.0
Focus
Focus
update()
Focus
Focus

Description:

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

Examples:
Since: 3.0.0
Focus
Focus