Merge pull request #6890 from ospira/process-callback-fix

Allow ProcessCallback To Work When Dealing With Arcade Bodies That Do Not Have GameObjects
This commit is contained in:
Richard Davey 2024-08-25 21:29:03 +01:00 committed by GitHub
commit 683ae16522
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -1395,7 +1395,7 @@ var World = new Class({
}
// They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort.
if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false)
if (processCallback && processCallback.call(callbackContext, (body1.gameObject || body1), (body2.gameObject || body2)) === false)
{
return result;
}

View file

@ -7,6 +7,10 @@
*
* For all other cases, `object1` and `object2` match the same arguments in `collide()` or `overlap()`.
*
* @param {(Phaser.Types.Physics.Arcade.GameObjectWithBody|Phaser.Tilemaps.Tile)} object1 - The first Game Object.
* @param {(Phaser.Types.Physics.Arcade.GameObjectWithBody|Phaser.Tilemaps.Tile)} object2 - The second Game Object.
*/
* Note you can receive back only a body if you passed in a body directly.
*
* You should only do this if the body intentionally has no associated game object (sprite, .etc).
*
* @param {(Phaser.Types.Physics.Arcade.GameObjectWithBody|Phaser.Physics.Arcade.Body|Phaser.Tilemaps.Tile)} object1 - The first Game Object.
* @param {(Phaser.Types.Physics.Arcade.GameObjectWithBody|Phaser.Physics.Arcade.Body|Phaser.Tilemaps.Tile)} object2 - The second Game Object.
*/