What is a LayoutComponent used for?

What is a LayoutComponent used for?


I’ve been looking at Widgets and Widget::setPositionPercent, which “Set the percent(x,y) of the widget in OpenGL coordinates”. There are some cocos2d-x tests for it, but they don’t cover too much.

Seems like you call widget->setLayoutComponentEnabled(true) and it starts working, but I’d like to be able read more about it.

Has anyone used it for their widgets? Is there some documentation available for it?


I second this, the efficiency of the absense of positioning based on numerical tab size seems rather convenient.


I’m not sure if the old wiki had any better docs about it. I do know we haven’t had good docs in this area for as long as I can remember. We probably should fix this.

I’ve never used layouts much. I always prefer to control it myself. I do so based on screen size and percentages.


For my last few games, I did it manually, then I started using Creator, but now I’ve started to use ui::Layout with some homebrewed helpers for managing setMargins and stuff like that, I recommend giving it a shot because it saves a decent amount of trial and error compiling and recompiling to position stuff properly.

I’m interested in LayoutComponent because it seems like it could be an extension of all the layout stuff, but I just don’t have an idea of how to use it properly.