Cocos Creator Feature Request

Hi,

I don’t know if I am doing something wrong but I would like to request this:
When you add a Layout like this

And then add 3 sprites within this layout like this

When I change the layout size using the widget component, the 3 sprite sizes change in size too because the Layout is set to Resize the CHILDREN
— BUT—
only the height gets resized and not the width of the sprite. This makes the sprite image look stretched. Is there anyway the width-height ratio stay the same? My sprite buttons are circles and it would be great if the height and width kept he same ratios.

Is there a work around for this or can I request this feature?
Thanks.

hi for this requirement I think layout is not very suitable.

From your child nodes’ name I guess they are icons and their width/height ratio should be fixed. Also the number of icons will not change in runtime.

Since the icon aspect ratio and icon numbers will not change, your container should keep the same aspect ratio as well, is that right?

You can give each of your child nodes a widget and set the width to go with container’s width, set the height to be 30% of container’s height (if there are 3 icons). In other words use percentage to set the size of children to match one third of container’s size.

Hi @nantas2.

Thanks for the quick reply, when you say container do you mean the Layout component?
I like using the Layout component because it spreads out the 3 icons evenly in the space that I want them to cover.
Are you saying I should set the Layout Resize Mode to NONE?

@nantas2 this is what my scene looks like

You said:

But what is container in this case? If it is not a Layout component then what should I use as a container?

Much appreciated.

By ‘container’ I did mean node with Layout component.

Now I see your scene, I think if you want evenly placed icons, you should use Container as Resize Mode.

If you also need the icons to scale up/down according to screen resolution, you may need to write a script to scale icons uniformly. Use Children as Resize mode will not keep the aspect ratio of the sprite.

I was afraid of that.

It’s not a problem writing the script but I was just hoping I could request the Children Resize Mode would keep the sprite scale ratio.

Ok, thanks!