Delete an item in a group

Hello everyone,
I’m trying to create a life system. When the character touch an bomb we removed one life (represented by a hearth) I’ve already create objects but I can’t delete one object.
lives = this.physics.add.staticGroup();
lives.create(300, 35, ‘hearth’);
lives.create(350, 35, ‘hearth’);
lives.create(400, 35, ‘hearth’);
//then character touch a bom

I try this but 2 hearth was removed
lives.getChildren().map(child => child.destroy())

Anyone can tell me where I’m I was wrong please?
Regards

I think I would just do

var children = lives.getChildren();

children[0].setVisible(true);
children[1].setVisible(true);
children[2].setVisible(false);

Hi @remi-boivin,
If you want to remove only one item from the group. You can use something like this:

lives.remove(lives.getLast(true), true);

I don’t know why your code does not delete all the elements of the group, but only 2. The map function should iterate all elements and return a new array.
Maybe I’m wrong, but if you are using hearts for the ui, you don’t need a physics group.
Regards.

Thanks it’s work.

Thanks for your answer.