0 votes

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:
enter image description here

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.
enter image description here

in Engine by (58 points)
edited by

Is this for gui element or for the game itself?

1 Answer

0 votes

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

by (9,786 points)

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 :/ I want to handle click event for each child of GridContainer separately.

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

TextureFrame has been superceded by TextureRect

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.