phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37k stars 7.09k forks source link

Allow ProcessCallback To Work When Dealing With Arcade Bodies That Do Not Have GameObjects #6890

Closed ospira closed 1 month ago

ospira commented 1 month ago

This PR

Describe the changes below:

Following up on a recent discussion in the discord / this commit this PR fixes a small bug in the separate() function.

On these lines: https://github.com/phaserjs/phaser/blob/master/src/physics/arcade/World.js#L1946-L1950 - we see that the "detached" arcade body (the Body without a game object) is treated as a sprite (it isBody - unlike a sprite that has the body property .body) but in the processCallback this same dual nature of "sprite" in this context is not applied in reverse, the process callback will only pass back game objects, leading to potential bugs in consuming code trying to run a processCallback on their detached body colliders. This fix implements the same check in reverse, if the body has no gameObject (no sprite) the body itself will be returned to the callback, so that it can be executed/evaluated appropriately.

photonstorm commented 1 month ago

👍