Hello,
I’m using the physics engine, and I’m attempting to have a box that covers multiple enemies and destroys all enemies within the box. I have a group called current_enemies, and the box is called hitBox.
On the create, I call :
this.physics.add.collide(hitBox, current_enemies, checkOverlap);
with the checkOverlap function being:
function checkOverlap(spriteA, spriteB) { spriteA.destroy() spriteB.destroy() }
This works, but unfortunately it only seems to destroys one enemy even if the hitBox collides with multiple enemies. I’m not sure how either loop the overlap function so that it goes through all overlaps, or if there’s a multiple collsion callback.
Any ideas?