# Match 2 sprites and destroy(Solved)

For questions about using Classic.

### » Wed Jul 06, 2011 8:26 pm

Iv'e spent 2 days trying to work this out.....and failed!

I'm not trying to make a 'memory game' but the logic is the same.

The game has 4 (picture) sprites: pv1, pv2, pv3, pv4, and a card sprite that covers each of them.

1, The player clicks on a card the opacity is set at 10%, revealing the 'picture sprite' below.
2, The player clicks on another card the opacity is set at 10%, revealing the'picture sprite' below.
3, If the 'pictures sprites' match, the cards and 'picture sprites' are destroyed and the player gets a match.
4, If the 'picture sprites' dont match, the cards reset, and the player tries again.
5, Once the player achieves the required number of matches, the player enters the next stage.

Iv'e seen various posts with solutions to this, but each one had about 100 seperate event's.

HELP?

chrisbrobs2011-07-17 21:02:11
B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

### » Wed Jul 06, 2011 8:34 pm

Are you using an array ?
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

### » Wed Jul 06, 2011 8:42 pm

[QUOTE=Magistross] Are you using an array ?[/QUOTE]

The 'picture sprites' are created using an array, but the 'cards' are added using -

+ System: For each Block
-> Block: Spawn object bonusCard on layer 4 (image point 0)

------------------------------------------------------

(Blocks = picture sprites)

B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

### » Wed Jul 06, 2011 8:50 pm

You need a variable(s) that keep track of the currently shown 'picture sprite' index(es). (set to -1 if none is shown)

Assuming the click event is on the 'cards', you have to keep track of the index of which 'picture sprite' it is hiding.

Upon clicking, if the indexes are set to -1, set them to the correct values, then show the picture.

If however the indexes are not set to -1, then check if the shown picture is the same as the one just clicked (still using indexes and what not).Magistross2011-07-06 20:50:36
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

### » Wed Jul 06, 2011 9:02 pm

[QUOTE=Magistross] You need a variable(s) that keep track of the currently shown 'picture sprite' index(es). (set to -1 if none is shown)

Assuming the click event is on the 'cards', you have to keep track of the index of which 'picture sprite' it is hiding.

Upon clicking, if the indexes are set to -1, set them to the correct values, then show the picture.

If however the indexes are not set to -1, then check if the shown picture is the same as the one just clicked (still using indexes and what not).[/QUOTE]

-----------------------------------------------------

Sound's easy......any chance of an example cap?

B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

### » Wed Jul 06, 2011 9:05 pm

I'm at work right now, but I will cook ya up an exemple when I get home in next hour. You might as well provide a cap with what you've already done so I can wrap my code around it.
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

### » Wed Jul 06, 2011 9:33 pm

I achieved this with a memory game some time ago.If i can find the cap i will post it.
B
23
S
3
G
7
Posts: 1,356
Reputation: 7,676

### » Wed Jul 06, 2011 9:37 pm

Here's a cap.

card match

There's a lot of stuff going in in this cap, so i have added a couple events to simplify things.

When you run the cap, click the button 'create card' to activate the group 'CARD MATCH' (the last one).

This is the part that i am stuck on.
B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

### » Wed Jul 06, 2011 9:39 pm

[QUOTE=DravenX] I achieved this with a memory game some time ago.If i can find the cap i will post it.[/QUOTE]

I downloaded your caps.....they work! I was just wondering if there was an easier way ?
B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

### » Wed Jul 06, 2011 9:52 pm

Here's a couple of things i tried:

Didn't work!

chrisbrobs2011-07-06 21:53:55
B
21
S
5
G
8
Posts: 1,215
Reputation: 7,838

Next

Return to Help & Support using Construct Classic

### Who is online

Users browsing this forum: No registered users and 0 guests