0 votes

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

Godot version v 3.3
in Engine by (418 points)

1 Answer

0 votes

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

by (8,152 points)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.