How do I create the following sequence/memory event?

0 favourites
  • 14 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi,

    I've been trying to make a game event where a character displays a random sequence of objects which the player then has to click on in the correct order, like in the sample image. Even a simple c3 file would be extremely useful if anyone has the time.

    Tagged:

  • An easy method is to use a text variable to store the sequence. For example, it can be a list of animation frames - "310". Which means that first you need to click sprite instance with frame 3, then 1, then 0.

    As player is clicking the sprites, save clicked frames in another variable:

    Set Result to (Result & Sprite.AnimationFrame)

    And once two variables are equal, this means that the sprites were clicked in the correct order.

  • Many thanks, dop2000.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've run into a minor problem. How do I get a different animation to play if a sprite is clicked in the wrong order?

  • If you took my advice with two variables (correct order and clicked order), then once the length of both variables is the same, check if they are equal. If not - this means that the clicked order was wrong.

    If you want to detect mistakes immediately when the first wrong picture is clicked, you need to do something like this:

     Compare variable clickedOrder not equal left(correctOrder,len(clickedOrder))
     // display animation for wrong order
    
  • Thanks dop2000, that was just what I was looking for.

    One last question. I have a row of four instances of the same sprite. When one is touched it's destroyed and is replaced using an instance variable, but this doesn't work if the sprite is playing the different animation. How do I get it to respawn?

  • Not sure I understand the question.

    If you are spawning the same sprite, then why destroy one and create another? Simply change the animation frame on it.

  • Thanks dop2000, changing the frame worked. I should know better than to post when I'm tired because I overlook things like this.

  • Hi,

    Is there a way to reverse the above sequence? As in, display the animation for the wrong order is displayed when the objects are clicked in the correct order?

    I can almost get this to work but only after all the objects have been clicked, not after the first clocked instance. I've tried using "Compare variable: clickedOrder not equal left(correctOrder,len(clickedOrder))" using "equal" instead but this didn't work.

  • Sounds like you have the right idea. Are clickedOrder and correctOrder both strings?

    Edit: dropbox.com/s/od4zgfohtuaqugy/compareorder_example.c3p

  • Hi oosyrag,

    Yes, both variables are strings. I've had another go but I'm still running into the same issue. It works when the first object is clicked but if I select objects in the correct order after this (for example, if the correct order was "0123" and I input "1123") it doesn't trigger the animation on the first "correct" object clicked after the incorrect one.

  • Oh I see, so you want to be able to continue with a correct answer after an incorrect one.

    In that case, you can check just the last entered answer with right(clickedorder,1) = mid(correctOrder,len(clickedOrder)-1,1).

    Alternatively, if they need to continue the series in the correct order, you can simply not record incorrect answers.

    Updated the example file.

  • Hi Wixey, I fleshed out Oosyrag's project file a bit. as it's the kind of work I'm interested in for my school. Here's a project file. Thanks

    dropbox.com/s/bsaaxkptisedsg3/Replicate%20Order.c3p

  • Many thanks oosyrag and VikasSanstha, this was just what I needed. :)

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