Applying collider to group

Is there a way to apply a collider to a physics group instead of each individual member of that group? Currently I have my platforms in a platforms group and I’m having to modify setSize() for every member of that group. I would love to be able to say this.platforms.setSize(x, y) instead of

this.platform1.setSize();
this.platform2.setSize();
this.platform3.setSize();
...etc

Hi Benstrocity,

You can iterate through the group children and set the size that way, for example.
this.platformGroup = this.physics.add.group();

this.platformGroup.children.each(function(platform) {
platform.setSize();
}, this);

Hopefully that should work :slight_smile:

1 Like

Beautiful. Makes sense, I don’t see why that won’t work. I’ll let you know.

Works like a charm. This will save me about 10 lines of code per level lol

1 Like