Physics.Arcade.Body#onCollide

onCollide : Phaser.Signal

A Signal that is dispatched when this Body collides with another Body.

You still need to call game.physics.arcade.collide in your update method in order
for this signal to be dispatched.

Usually you'd pass a callback to the collide method, but this signal provides for
a different level of notification.

Due to the potentially high volume of signals this could create it is disabled by default.

To use this feature set this property to a Phaser.Signal: sprite.body.onCollide = new Phaser.Signal()
and it will be called when a collision happens, passing two arguments: the sprites which collided.
The first sprite in the argument is always the owner of this Body.

If two Bodies with this Signal set collide, both will dispatch the Signal.

Source code: physics/arcade/Body.js (Line 221)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.