Signals not working in 2D array of scenes

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

I want to make a memory game in Godot and i’m trying to do this by following the tutorial series made by Mister Taft Creates on youtube for a match 3 game. I basically made the same code for generating the 2D array and instaciating the scenes with the cards but i want each card to grow in scale a little when i hover the mouse over it.

I’ve made a main card scene from witch all the other cards inherit from and in this scene i’ve made an Area2D node to use the on_mouse_entered() signal, then i attached a GDScript to the card node with the following code :

extends Node2D

export (String) var card_image

func _on_Area2D_mouse_entered():
print(“signal working”)
$ReescaleAnimation.play(“upscale”)
pass

func _on_Area2D_mouse_exited():
print(“signal also working”)
$ReescaleAnimation.play(“deescale”)
pass

it really works fine when i play the card scene but when i play the scene with the grid of cards it does nothing and i have no idea why…

note: not even the print command works in the grid scene.

#PRINTS

  • Card scene:

  • Grid scene:

:bust_in_silhouette: Reply From: Eric Ellingson

Can you try something like:

Scene Tree:

Card (Card.gd)
    Area2D
         CollisionShape2D

Card.gd

func _ready():
    $Area2D.connect("mouseentered", self, "_mouse_entered")
    $Area2D.connect("mouseexited", self, "_mouse_exited")

func _mouse_entered():
    # your code here

func _mouse_exited():
    # your code here
:bust_in_silhouette: Reply From: FelipeRattu

I’ve found a solution… thank you for your answer Eric Ellingson :smiley:

The problem was that i needed to set the mouse filter in the background Texture Rect to Ignore. Then everything worked fine.

i’m using Godot 3.1 btw