GridContainer with Sprites/Area2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By qazwsx
:warning: Old Version Published before Godot 3 was released.

I am trying to make a grid of clickable objects (Area2D) that contain AnimatedSprite and CollisionShape2D.
I created Scene which represents Cell in the grid and then added the Cells to Grid in main scene from GDScript. Unfortunately I noticed that all the Cells are located in the same position (despite how many columns are set).
I have also tried to do the same with Sprite and other objects from Node2D and the effect is the same. Can you point me what I am doing wrong or eventually provide the correct pattern how it should be done? See below minimal example (tree) that represents the issue:

Each sprite has texture that contains some number. When I run the program I see only the Sprite that is on the bottom under the GridContainer (Sprite3 - which has number “2” on white background). The rest of the Sprites are behind it. See below.

Is this for gui element or for the game itself?

puppetmaster- | 2016-08-12 14:31

:bust_in_silhouette: Reply From: volzhs

The Control and Node2D is under CanvasItem which is used for 2D.
But, Control is implemented in different way with Node2D which has Sprite.
You can see the hierarchy in Create New Node window.

So, It’s best to use Control node with Control node.
Try to use TextureFrame node which is under Control instead of Sprite

Ok, this way it will be displayed in correct way but the events are not working… Only _input function works but it will affect all TextureFrame objects under GridContainer :confused: I want to handle click event for each child of GridContainer separately.

qazwsx | 2016-08-12 18:30

I’m having a similar issue did you ever find a work around?

namathos | 2020-05-15 15:48

TextureFrame has been superceded by TextureRect

SteveSmith | 2022-09-28 12:38