0 votes

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")
in Engine by (12 points)

1 Answer

0 votes

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!

enter image description here

by (23 points)

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?

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.

Categories