Attention | Topic was automatically imported from the old Question2Answer platform. | |
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")