Area2D click

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

I’m trying to make a memory game.

The structure of my scene:

Node2D
→ TextureRect
→ Control
→ Area2D
-----> Sprite
-----> CollisionShape2D

When I start the game without the visibility of the TextureRect and Control my gdscript works well, but when they are visible doesn’t work.
The code is attached on Area2D:

extends Area2D

var card_name
var card_face
var card_back
var click_enabled

func _ready():
	set_process_input(true)
	click_enabled = true
	card_name = "Empty"
	card_face = preload("res://Assets/MemoryGame/blank-card.png")
	card_back = preload("res://Assets/MemoryGame/blank-card.png")
	get_node("Sprite").texture = card_back

func _input_event(viewport, event, shape_idx):
	if event is InputEventMouseButton \
	and event.button_index == BUTTON_LEFT \
	and event.pressed:
		self.on_click()

func on_click():
	print("clicked")
:bust_in_silhouette: Reply From: Giiltham

Hi! to make sure the texture rect is not capturing your mouse, click on your texture rect, and then in the inspector find “Mouse”, inside it, change the property “Filter” to ignore so it ignore the mouse. Hope it helped!

Thanks for the reply.
In the case of TextureRect your suggestion worked, but in the case of Control for my GUI the problem persists. Do you have any idea?

mockingjay01 | 2020-08-13 14:45