In Phaser version 3.19.0 and version 3.17.0 (the only 2 versions I’ve checked) some collision objects get returned in reverse of what’s expected. So when changing from a single sprite to a group, it causes issues.
Version 3.19.0 Line 95870 - the function “collideHandler” contains the return functions:
// A Body
return this.collideSpriteVsSprite(object1, object2, … )
return this.collideSpriteVsGroup(object1, object2, … )
return this.collideSpriteVsTilemapLayer(object1, object2, … )
// GROUPS
return this.collideSpriteVsGroup(object2, object1, … ) <<— the offending line
return this.collideGroupVsGroup(object1, object2, … )
return this.collideGroupVsTilemapLayer(object1, object2, … )
// TILEMAP LAYERS
return this.collideSpriteVsTilemapLayer(object2, object1, … ) <<— probable issues here too
return this.collideGroupVsTilemapLayer(object2, object1, … ) <<— probable issues here too
I was originally testing a sprite (object1) against a sprite (object2) which invoked “collideSpriteVsSprite” which returns (object1, object2). I changed the first sprite to a group which invokes “collideSpriteVsGroup”, which then swaps the output to (object2, object1).
Yes, I understand that I can easily swap my sprite and group, and similarly when I’m testing a sprite against sprite, reverse the order to match when I’m testing against a group.
I would suggest as an addition or alternate in the GROUPS category, a method of “collideGroupVsSprite” so the output remains in the order of (object1, object2).