Various ways to iterate an element in a group in Phaser 3

Option 1 –

Phaser.Actions.Call(group.getChildren(), function(sprite) {
    this.children.bringToTop(sprite);
}, this);

Option 2 –

group.children.each(function(sprite) {
  this.children.bringToTop(sprite);
}, this);

Option 3 –

group.getChildren().forEach(function(sprite) {
    this.children.bringToTop(sprite);
}, this);

 


Leave A Comment

Your email address will not be published. Required fields are marked *