+1 vote

Hello Godot community,

Below is the structure I'm having :
Control
--->GridContainer
------> Area2D
------------> TextureRect
------------> CollisionShape2D

When I connect the inputevent signal of my node Aread 2D to the main gd script (in the same scene), the follow code is not working :

func _on_DominoePieceA2D_input_event(viewport, event, shape_idx):
    if (event is InputEventScreenTouch):
        if (event.is_pressed()):
            print_debug("bingooooo")

I do receive an event, but is_pressed returns false, moreover, it's not working when I export it on phone.
So I was wondering if the structure I'm having (control and Node2D) is a valid structure.

What I'm trying to do is having images in a container, I'm trying to perform a drag&drop/click on those in order to move them into another container, so if my implementation is not valid, I'm open for suggestions :).

Thank you for any help.
Seli

in Engine by (24 points)

1 Answer

0 votes
Best answer

Hi Seli,
I would recommend using Texturerects without Areas and collision-shapes. Areas are mostly for receiving information from other physics driven elements (like collisions or if a body enters). You can use gui_input(event) signal. You should also have a look at the GUI Drag and Drop Demo. If you have any further questions of how to use this tips feel free to ask.

Good luck. Jowan-Spooner

P.S. I don't know why what you do is not working and it's porbably not completely wrong and should somehow be possible, nevertheless the way I described above is more common for what you seem to try.

by (788 points)
selected by
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 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 webmaster@godotengine.org with your username.