0 votes
func _on_Area2D_input_event(viewport, event, shape_idx):

the function is triggered only when the mouse button is released in it and at the same time if the pressed mouse button was entered from outside the object, and not in it.


Godot version 3.2.3.stable.official
in Engine by (159 points)
retagged by

How do you want the Area2D to work? Since a mouse button click is an input event, it looks like the signal is working.

how then to check the mouse click on area2D?

I realized that the color rect overlapped the collision body

1 Answer

0 votes

If you want to listen only to the left mouse button click, this is the code:

func _on_Area2D_input_event(viewport, event, shape_idx):
    if event is InputEventMouseButton:
        if event.button_index == BUTTON_LEFT and event.pressed:
            print("Left button was clicked at ", event.position)
by (41 points)
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.