[Solved] Previous animation won't play. 1 to 2 works but not 2 to 1

I’m making a memory game with flowers and when you uncover the card, its name appears. I made a sprite for all the names, with every name on separate animation. This is how the code looks:

Everything works good but I noticed a strange behavior with the order you uncoer the cards. Let’s say we have a poppy and a daisy. Poppy’s name animation is number 1, and daisy’s is number 2. When I uncover poppy first, it’s name appear and when I uncover daisy, displayed name changes to daisy’s, that’s how it should work. But when I uncover daisy first, it’s name appears and then uncover the poppy, poppy name won’t be displayed and it will still be showing daisy. I don’t know what causes this problem but I noticed it appears in every case when it should display the animation with lower number than the first, eg.: 7 to 3, 10 to 8 etc. I also tried it wih action “Change the animation by name” but the same problem still appears.

I’m going on an assumption that each card has a display name attached.

If so, you need to select which display name to change, otherwise GDevelop will do all of them. And because Daisy is checked after Poppy, all the display names are changed to Daisy.

So ideally you need to link each display name to a card. Let us know if you need help with this.

I also assume Cards is the object group for all the cards. If so, then you could reduce the number of events from the 19 you have to 3 or 4. It would require a little bit of setup, but it would mean you could add or remove cards without having to add or remove events. Let us know if you’d like to try this.

Hi, thank you for your answer. Yes, Cards is the group of all cards. I’d honestly need some help with this as it’s the first time I’m doing this kind of game, so the explanation would be very much appreaciated!

I have one more question. It’s less important and I didn’t want to create a new topic since all the context of the game is here. How can I make it that when a pair is found, these two cards are displayed on screen longer than normally? Example, you got the pair wrong, the cards get covered after 2 seconds. You got the pair, the cards dissapear after 5 seconds.

I’d look at using a timer. At the beginning of the scene, start a scene timer (say called “coverTimer”) and then pause it. Also create a scene variable called coverTimerDelay, and set it to 999 (just an arbitrary large number).

Create a new event that checks if coverTimer > coverTimerDelay, and has actions that covers the cards, resets the timer coverTimer and pauses it.

In the logic that determines whether the pair of cards are correct or not, set set coverTimerDelay to the appropriate value (2 or 5), start the timer coverTimer and unpause it.

I’ll get into the linking explanation soon.

Thank you so much for your help, but could I ask how such events would have look? I tried to recreate it as you said but got a bit lost in making events.

Hi, sorry for disturbing but I have to have the game finished in a few days (a school project) and the problem with names is actually the only thing holding me back. I tried other methods with separate sprites, text etc but it still doesn’t work so I’d be glad if you could show any tutorials or examples with this linking. It’s a really weird problem, as I said, it works in one way but not in the other way

No worries. I think I’ve misunderstood how you use names. I though it was one name on each card, but now I assume it’s a text box on the screen, that shows the name of the flower that’s on the card that’s just been turned over. In which case, linking is not correct. Also, I’m assuming each card has a front and back animation.

If those assumptions are correct, do the following:

  1. Add an instance variable to each card object, name it “AnimationNumber” and assign it the value of the name animation.

  1. Use the following events for the cover timer (you’ll need to fill in the 2 event conditions that determine match or no match) :

  1. Include this sort of code when a card is uncovered. It’ll set Names to the animation number of the card just turned over.

  1. Remove all of the events that were screen snipped in your first post :

I think that should see you right.

1 Like

Okay, I feel like I’m close! The thing with names totally worked but I still need to get the cover timer working. I’ll show you my events:

Something must be wrong, because when I choose 2 cards, they don’t get covered again and everything is stuck.
This “Trigger once” at the end of 1st image and beginning of 2nd is the same event

You realise the trigger once means this sub events are actioned once and that’s it until the scene is rerun? Is that what you want to happen?

I think you may be better off adding a tween behaviour to all the cards (sorry, a bit of extra work, bt it makes the events a lot simpler), and using an opacity tween that deletes the object when it’s finished.

Remove this :

And put these subevents in the right place on your first screen snip :

Then set up an opacity tween :

To set up the tween, you may need to do it for one of the cards, and then change the card object with the cards group :




1 Like

Okay, this works, but only once, in the first turn. After the cards get covered, I can click on all the other cards and they don’t get covered, like it ignored all the events

You 'don’t appear to be resetting num_selected when coverTimer is greater than the time delay (last event in the screen snip).


THIS WORKS! Thank you so much for all the help and patience! The thread can be closed, again, thank you SO much