0 votes

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 onmouseentered() signal, then i attached a GDScript to the card node with the following code :

extends Node2D

export (String) var card_image

func onArea2Dmouseentered():
print("signal working")
$ReescaleAnimation.play("upscale")
pass

func onArea2Dmouseexited():
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:

enter image description here

  • Grid scene:

enter image description here

in Engine by (69 points)

2 Answers

0 votes

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
by (1,650 points)
0 votes

I've found a solution... thank you for your answer Eric Ellingson :D

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

by (69 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.