How to Prevent Touching Image Sprites At The Same Time

I am trying to make a memory game. I know there are several guides to do that but I tried my own way with image sprites inside a canvas. My problem is:

When you touch the middle point of 4 image sprites, all of 4 gets opened. Normally sequence is like this: One sprite is opened and then second is opened. If they are same they disappear, if not they will be closed. In this case 4 sprites are opened. How can I fix this?

1 Like

I used image sprites but could not fix Multi touch.
I used dynamic card view/dynamic image and dynamic buttons but this time dynamic card views dont have enable disable fuction. So I gave up… Just want to ask

Using 12 or more buttons with 12 or more arragements in one screen create problems such as crashing?

Well, im using 10+ Arrangements for multiple screens and 30+ buttons and its working fine.

Can you show your blocks for this procediment please?

I deleted because I had no success. But I used “When Any Image Sprite Touched” block for that. There were 12 image sprites in canvas as they look gridview 3x4. I trid “Touch up” “Touch down” but same. When you put your finger to the mid point of 4 image sprite, they all are touched up somehow.

Then I trid dynamic card view but there was no option for enabling or disabling for that blocks. I need enabling and disabling process for the memory game. For example when you open two card, it must be disabled to touch other cards for a while etc.

If using 12 or more buttons with 12 arrangements won’t create problem I can try that with button animations. That will be better for me however I like to deal with Imagesprites.

1 Like

Well, i have a solution that may help you,
Create a variable with a empty list
Use the When any button pressed block
Check if the button is in a list(you need to make a list with this 12 buttons) AND the variable is empty
Store this component in variable list
When you click in another button they will check again if is in list(12 buttons) AND check if the variable list leght is =< 2 (if the leght of the list for more than 2 they will ignore the procediment)
Check if is the same image or anything you’re using for the game
And reseting the variable
I dont know if this will work and i didn’t try this because i’m away from pc but you can give a try

1 Like

Actually I did it with image sprites when first sprite touched it makes the global opencard variable 1, when second sprite touched it makes the global opencard variable 2 and then I added a procedure disabling touching all sprites in the list. If the both sprites images are same and then I set the visibilty of them false both. then enable all sprites again.

But in this process user can touch more than 2 sprites at the same time somehow. I couldnt fix that. I’d better try with buttons and arragements now. I will let you know the result mate. thanks.

I liked your logic, i dont know why this is not working for you, if you want, you can share your AIA fila here or you can message me, maybe we can solve this.

I deleted blocks but let me try to remake it when I find suitable time and then let you know.

1 Like

In my current app the way I do it is by disabling every sprite once a sprite is touched, then I enable the touched sprite. When touched up, I Enable all sprites again.

Another way is to use a list. Say you have 10 sprites, then create a list with 10 FALSE values. When a sprite is touched, set the corresponding list value to TRUE. For every touched down event, use IF is in list TRUE (check for a true in the list) then do nothing, IF there is no true in the list then set the image sprites value to TRUE in the list and do the action you want to do. Then when touched up, check if the sprites value is TRUE then set to FAlSE.

I can add the blocks because the explanation is a bit messy, but that first method I mentioned works well for me. And it works for other actions like dragged.

2 Likes

I was using “Any Image Sprite Touched” block but maybe I was putting disable procedure to wrong place. I am gonna try your solution. Thanks really.

1 Like

For the any image sprite blocks you can use the same logic there, that’s actually why I didn’t use hardcoded indexes in the example. Good luck!

And just note again, I use the disable/enable method I mentioned since I started with that and don’t want to restart.