click sprite(s) then have them perform

Get help using Construct 2

Post » Tue Feb 18, 2014 1:31 pm

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
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Tue Feb 18, 2014 1:42 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Feb 18, 2014 1:46 pm

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'dGuizmus2014-02-18 13:46:54
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Tue Feb 18, 2014 1:51 pm

Make instance variable in those sprites, give the value per click, and use the event "Pick highest/lowest".
B
23
S
8
G
1
Posts: 172
Reputation: 2,780

Post » Tue Feb 18, 2014 1:58 pm

[QUOTE=LittleStain] 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.[/QUOTE]
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.
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Tue Feb 18, 2014 1:59 pm

[QUOTE=Guizmus] It makes sense.
[/QUOTE]

thanks..i will look into this...much appreciated
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Tue Feb 18, 2014 2:06 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Feb 18, 2014 2:31 pm

[QUOTE=LittleStain] 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.
[/QUOTE]

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.
B
7
S
2
Posts: 158
Reputation: 1,021

Post » Tue Feb 18, 2014 2:48 pm

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.


I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Feb 18, 2014 2:51 pm

Thank You! yea, I have a different capx that I'm using for this...
B
7
S
2
Posts: 158
Reputation: 1,021

Next

Return to How do I....?

Who is online

Users browsing this forum: lahbach, ST314, Waltuo and 18 guests