click sprite(s) then have them perform

  • hopefully it's an easy answer.

    example:

    have 4 sprites.

    They all have different poses ( arm up, arm down, leg up, leg down)

    I would like the player to click each sprite in whatever order they want, hit a button and then have those spites play back the order that they were clicked?

    Does that make sense?

    Any help would be appreciated

  • From what I've seen you have the basics for that already in place in your game.

    What is it that you'd really want to know, for setting the animation has already been implemented.

  • It makes sense.

    Let's call your sprites "HumanPiece". Yes, all the sprites are the same object. You have 4 frames in this objects, each frame being one of your arms or legs (don't forget to set the animation speed to 0). On the sprite object, we add a variable "ClickedOrder", default to 0.

    Now, we start the events. A global variable, "ClickedNumber", set to 0, will remember how many pieces have been clicked already.

    The first event has a double condition, and handles the click :

    On HumanPiece.Click

    IF HumanPiece.ClickedOrder = 0

    => Add 1 to ClickedNumber

    => HumanPiece.ClickedOrder = ClickedNumber

    That way, if a piece is clicked, it won't do a thing if it had already been clicked, but will save what order it has been clicked in if it wasn't clicked before.

    The second event will handle the display of the order. It will only check if "ClickedNumber" = 4, and if it does, will handle what you called the playback. I don't know how you want it to display, but it shouldn't be hard from here, as all those HumanPieces have a variable (Self.ClickedOrder) going from 1 to 4, indicating in what order they were clicked.

    Edit : ninja'd

  • Make instance variable in those sprites, give the value per click, and use the event "Pick highest/lowest".

  • From what I've seen you have the basics for that already in place in your game.

    What is it that you'd really want to know, for setting the animation has already been implemented.

    yea, but the way I have it setup now is that the animation plays and then the player chooses what was just played.

    I was looking to make it so that the player chooses what get's played and then the animation plays. Almost the opposite of what i have now.

    I can figure out how to click the sprite but what i don't know is the "if/then" type formula.

    Sort of if this is clicked first then play this first. if that is clicked second then play this first and then play that second.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It makes sense.

    thanks..i will look into this...much appreciated

  • Like I said, it's all already there in your events.

    You'd only have to change the triggers.

    Seems like at the moment you don't understand the events in your own game.

  • Like I said, it's all already there in your events.

    You'd only have to change the triggers.

    Seems like at the moment you don't understand the events in your own game.

    heck no I don't! I just started playing around with construct2.

    and it's not so much a game as a learning experience.

    I'm going through some of the tutorials but to grasp my head around all of it is a bit daunting. especially when you know what you want to try but you don't have a firm grasp of the way it all ties together.

    that's why, for me at least and for the moment, If I ask how to do this or how to do that I can try it and hopefully remember what that particular event does and how it works.

  • Ok, so in the capx the way you have it now the names of the animations are added to a string.

    When pushing the buttons on the right the names are added to another string and those two strings are compared to see if the original sequence is the same as the user defined sequence.

    The animations are triggered by setting the variable state to "show" and adding to the variable "showNumber" and using that variable to pick the right animation from the string with:

    tokenat(showtext.text,stand.shownumber,"_")

    So to make it work with userinput

    you'd have to append to showtext the name of your animation followed by _

    And when pressed play set state to "show" and add 1 to the variable "showNumber" every 3 seconds.

    That's about it!

    But it might be a wise choice to try and create these actions with events you can understand, instead of using the capx as is.

  • Thank You! yea, I have a different capx that I'm using for this...

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