Adaptive layout for children inside Container

Hello! I was wondering if there was already a method built-in to display the gameObjects inside a container.

For example :

adaptiveWidth : Set the width of the container according to the width of all children gameObject accumuled

adaptiveHeight : Set the height of the container according to the height of all children gameObject accumuled

alignLeft : Align all children gameObject to the left

alignCenter : Align all children gameObject to the center

alignRight : Align all children gameObject to the right

jusityContent : Justify all children gameObject

wrapContent : if the children gameObject should be wrap

gridLayout : set the child gameObject according to a grid

[…]

I was looking at the methods inside the Phaser.GameObjects.Container and I did not found any. Is there already a class inside the Phaser Library that could help achieve this or I will have to make custom methods to achieve that?

Thanks!

You can do

const { width, height } = container.getBounds();

container.setSize(width, height);

And then use

1 Like