Help with displaying Node2ds on screen like cards in a hand

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

I need help with an especific task. I am making a card game and I have Node2d scenes that serve as the visual representation of the cards. Question is, how would I go about auto-handling their position in the screen, when I add them as childs? Of course, one way would be to have a premade list of positions I want, and depending on the size of the hand (amount of cards added as childs), use these positions to , well, position the cards. But there must be a proper way of doing it maybe with Control Nodes

Control Nodes have always been kinda my weak point, so the awnser could be obvious.

P.D. I know I should get on with reading and understanding the Controls documentation, but I can never muster the courage haha

:bust_in_silhouette: Reply From: exuin

You could use a VBoxContainer or HBoxContainer or GridContainer to organize the children. It all depends on how you want the cards arranged.

If I add Node2D childs to an HBoxContainer or GridContainer, they just pile them on the same spot. Maybe this is due to the fact that they only sort other control nodes?

I have written a “sorting” function in a Node2D I am using as a container and it works fine, so it itsnt like a need an awnser, but just wondering if there is a better way to do it. I guessed that it could be done with Control type nodes, I just dont know how.

Pomelo | 2022-06-14 16:22