Match 2 sprites and destroy(Solved)

This forum is currently in read-only mode.
0 favourites
From the Asset Store
snake and ladder game with two characters: turtle and rabbit!
  • 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.

    <img src="http://dl.dropbox.com/u/22173473/matchup.png" border="0" />

    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?

  • Are you using an array ?

  • Are you using an array ?

    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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

  • 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).

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

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

  • 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.

  • I achieved this with a memory game some time ago.If i can find the cap i will post it.

  • 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.

  • I achieved this with a memory game some time ago.If i can find the cap i will post it.

    I downloaded your caps.....they work! I was just wondering if there was an easier way ?

  • Here's a couple of things i tried:

    <img src="http://dl.dropbox.com/u/22173473/PROGRESS.png" border="0" />

    Didn't work!

  • I can't seem to find where you actually put data in the array... am I missing something ?

  • Here's an 11 event example.

    http://dl.dropbox.com/u/5426011/examples5/cardmatch.cap

    Thanks ROJOhOund, this looks promising !

    On first run, i noticed that that cap only has 3 animation frames, does it work with 4?

    Sorry for silly question ROJOhound, it does !

    Thanks for you help.

  • I can't seem to find where you actually put data in the array... am I missing something ?

    The example cap was just to give you an idea of what i was trying to achieve! Not sure if the values matched my question exactly.

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

    I think ROJOhound has come up with solution though (again) <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Here I've done another example using an Array as I explained.

Jump to:
Active Users
There are 3 visitors browsing this topic (0 users and 3 guests)