Phaser API Documentation

  Version: 
addOverlap(object1, object2, [collideCallback], [processCallback], [callbackContext])

Description:

Creates a new Overlap Collider object and adds it to the simulation.

A Collider is a way to automatically perform overlap checks between two objects, calling the collide and process callbacks if they occur.

Colliders are run as part of the World update, after all of the Bodies have updated.

By creating a Collider you don't need then call World.overlap in your update loop, as it will be handled for you automatically.

Parameters:

name type arguments description
object1 Phaser.Types.Physics.Arcade.ArcadeColliderType

The first object to check for overlap.

object2 Phaser.Types.Physics.Arcade.ArcadeColliderType

The second object to check for overlap.

collideCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects overlap.

processCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects overlap. Must return a boolean.

callbackContext * <optional>

The scope in which to call the callbacks.

Returns:
Description:

The Collider that was created.

Since: 3.0.0