Physics.Arcade#overlap()

overlap(object1, object2, overlapCallback, processCallback, callbackContext) → {boolean}

Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters.
You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks.
Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results.
Both the first and second parameter can be arrays of objects, of differing types.
If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter.
NOTE: This function is not recursive, and will not test against children of objects passed (i.e. Groups within Groups).

Parameters
Name Type Argument Default Description
object1 Phaser.Sprite | Phaser.Group | Phaser.Particles.Emitter | array

The first object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter.

object2 Phaser.Sprite | Phaser.Group | Phaser.Particles.Emitter | array

The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter.

overlapCallback function <optional>
null

An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.

processCallback function <optional>
null

A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if this callback returns true.

callbackContext object <optional>

The context in which to run the callbacks.

Returns
boolean -

True if an overlap occurred otherwise false.

Source code: physics/arcade/World.js (Line 318)
doc_phaser
2017-02-14 10:59:05
Comments
Leave a Comment

Please login to continue.