Forum Discussion

sbs_ramim's avatar
sbs_ramim
Reel Rookie
5 years ago

Centering items using LayoutGroup

I feel very stupid as I ask this but I don't know why I cannot horizontally center items on the screen. So this is what I have under my "MainScene" children node:

 

<LayoutGroup
	width="2560"
	height="500" 
	layoutDirection="horiz"
	horizAlignment="center"
	vertAlignment="center"
	>
		<Rectangle
		width="500"
		height="500"
		color="0xff0000ff"
		horizAlignment="center"
		vertAlignment="center"
		/>  
</LayoutGroup>	 

As you can see, I've set alignment as "center" in both the parent and the child rectangle, and I've tried switching between layout direction "horiz" and "vert", but still, the red square appears at the top left corner. Can someone identify what am I doing wrong here?
Thank you 

 

No RepliesBe the first to reply