How to place a Scene next to another one?

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

I know, this seems like a pretty easy question, but the more I think about it, the more weird it gets for me to understand. In my code, I iterate some times, and with each iteration I want to place a scene next to the previous one (if there is a previous one, of course). I want to be able to place this scene sometimes on top/at the bottom/to the right/to the left bounds of the previous one, so that they do not get overlapped, like a TileMap, but with scenes instead of tiles. Is there a way to do this with a Node2D, or will I be forced to use some other type of node like a TileMap or even a RigidBody?

:bust_in_silhouette: Reply From: exuin

Just have a variable that represents the size of the scene and then add that size to the position of the next scene so that they don’t overlap.

I thought about that, but what if I do not know the size? Can I get it from the node?

SebSharper | 2021-09-07 00:05

No, Node2D doesn’t have a “size” property. It really depends on what “size” means. Is it the sprite size? Then you can use the width and height of the sprite.

exuin | 2021-09-07 03:44