- Edited
Hi there,
As my first project in Godot, I have chosen to make a 2D memory game.
I would like to propose multiple card sets, and for each of them, let the user choose the number of different cards to play with.
For now, I'm just trying to display the cards on the board and make them flip when clicked on.
My problem is related to the card scene I've created. I have put a button in this scene to detect the pressed
signal, when the player clicks on a card to flip it.
When I instantiate this scene multiple times (one instance for each card), whatever card I click on, only one instance is flipped (now it's the first; at some point it was the last; I don't know why).
I've tried different things, such as:
- Setting up the signal with code
- Setting up the signal in the main script instead of the card's one
- Setting up a custom signal with a parameter to pass the instance reference
connect("pressed", flip_card.bind(added_card)
, but it's always the same reference that is passed
I don't understand why it doesn't work and how I should write this differently.
The source code is available here
There are 3 scripts:
- main.gd is attached to the main scene
- card.gd is attached to the card scene
- card_set.gd is a class that I use to generate a list of cards by looking into the card_sets folder, but I don't think the problem is here