How to add Node2D in Control correctly?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zxf

I want to show an AnimatedSprite2D in a BoxContainer, but the child can’t take the right position and it can’t blow up the parent’s size, I have to manually adjust position and size every time when the scene changed. I am new to godot, it’s there a better way to do this ?

:bust_in_silhouette: Reply From: AlexSand

Maybe you can add a control node in between?
Something like this:
BoxContainer
→ Control
→ Sprite
You should set the minsize of the control to ensure it takes some space in the boxcontainer, and set the position of the sprite

Thanks for your good idea. I use a Control as the parent of the AnimatedSprite2D now, than set the parent’s size and the child’s position, it work as expected. Now it look like this:
BoxContainer
→ Control
→ -> Sprite
→ OtherControls

Zxf | 2023-04-15 13:51