Group vs layer vs container

I just started using Phaser v3 a few days ago.

I have a bunch of graphic and text objects that are spaced out on the screen how I want. I want to move them all together in a circular path.

I thought that if I put them all in the group, I can then use .setX, .setY but that makes the graphic objects move correctly but the text objects snap to where the x,y value is being set on the group.

I then noticed that there is also a layer and a container object.

What is the proper way to “group” things in a scene so that I can get a parent/child relationship and if I adjust the parent, then the parent’s transform control the pose of all the children relative to it.

What are the differences between groups, containers and layers and when I should choose one over the other?

Container.

Could someone explain the differences between groups, containers and layers and when I should choose one over the other?

A group is just a list, a logical collection. It’s not displayable. Group methods like setX() are just shortcuts setting properties of the group members.

A layer is a visual collection, but it doesn’t do any transforms, only alpha and visibility and masking.

A container is a display container that transforms its children.

1 Like