Memory Game - Functionality Question

Problem: Hello, I am using your Memory Game project to create my own, and I noticed that you can easily click on all the cards quickly and they all display. Is there any way to disable clickability of the other cards if two cards are currently turned? I’ve seen other examples of memory game where you can only have two cards turned over at the same time. I was hoping to do that with my projects to avoid users cheating.

I also have one other question. How is it possible to delay the disappearance of the cards if there is a match? Right now they disappear so quickly and I’d like there to be a little delay before that happens. Thx!

ActivePresenter version: 8.5.7

OS: MacOS Monterey 12.3.1

Project example (yours functions the same on the atomi site):

Hi Sarah,

For your questions, we suggest the solution as follows.

  1. Disable clickability of the other cards if two cards are currently turned.
  • Add a number variable, name it “count”.
  • Add the Adjust Variable actions and conditions to the advanced actions of the game as shown below:

  • Add the condition to the On Click event of each object like this:

  1. Delay the disappearance of the cards if there is a match.

This action can be done with some codes. However, it’s quite complicated and takes time to do.
Therefore, we suggest you extend the Effect Duration of the Hide Object actions in the advanced actions when the objects match.

Kindly take a look at our sample project if it meets your needs.
memorygame.approj (1.0 MB)

Best Regards,
Huyen

Wow, thanks so much. Awesome instructions! I have implemented them and it seemed to be working great, but now I noticed a little glitch. Perhaps this was always happening and I didn’t realize it before. It’s probably not that likely that a user would do this, but if you click on a card once or twice quickly as it’s turning back over, it seems to disable the ability to click on any two cards at once in the future. You can only click on one other card at a time after that. It’s quite strange. If you cannot produce it as I describe, perhaps i can send a screen recording. Is this something you’d be able to help with?

Revised game is here:

Revised project file is here:

Thanks!

Hi Sarah,

It’s difficult to fix this issue with just predefined actions and conditions, so I use JavaScript as in this project:
Memory Game JS.approj (772 KB)

For your existing project, please remove all events attached to your cards and all variables (except score variable), and replace the script in the slide On Load event by the script in this project.
Please remember to update the object name in the script.

Regards

This is fantastic thank you! I like the teeter effect so much better! One more question (i think) - if i want to add a little sound each time there’s a match, how would I add that to the js? I want to add the built-in sound “correct 2” whenever there’s a match to go along with the teeter effect and disappear.

Thanks again, you guys are awesome

Hi Sarah,

You can do as follows:

  1. Insert the sound “correct 2” to the slide, set it as “Background Music” and “Autoplay” in Properties pane > Media tab > Audio section > Playback Options
    Set it “Initially Hidden” in Properties pane > Size & Properties tab > Timing section so that it doesn’t play automatically at the beginning.
  2. Add a timeline called “correctsound” (or another meaningfull name), add an “Appear” effect of the sound object to the timeline.
  3. Add prez.startTimeline('correctsound'); statement at the beginning of the function function match(object1, object2) in the script
    image

Regards

Nevermind… figured this out. Thanks for all your help!!!

Great thanks, followed your instrux and it works perfect when there’s a match, but the sound also plays as soon as the game loads. How to avoid that?

I’ve updated my answer above (added Initial hidden for the sound) so that it can help other users.