Overlap multiple objects

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?

It loops internally but hitBox can’t cause any collisions after it’s been destroyed.

Thanks for the response,
How would I be best to check everything has been destroyed before destroying the hitbox?

You could set a flag in checkOverlap() then check it in update() and destroy the hitBox there.