Physics.P2.Body#createBodyCallback()

createBodyCallback(object, callback, callbackContext)

Sets a callback to be fired any time a shape in this Body impacts with a shape in the given Body. The impact test is performed against body.id values.
The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body.
Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening.
It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate.

Parameters
Name Type Description
object Phaser.Sprite | Phaser.TileSprite | Phaser.Physics.P2.Body | p2.Body

The object to send impact events for.

callback function

The callback to fire on impact. Set to null to clear a previously set callback.

callbackContext object

The context under which the callback will fire.

Source code: physics/p2/Body.js (Line 180)
doc_phaser
2017-02-14 11:01:57
Comments
Leave a Comment

Please login to continue.