How do I make multiple sequence key commands?

Just started using Construct 2? Post your questions here

Post » Tue Nov 25, 2014 4:09 pm

Hello everyone,

I searched the forums but could not find a suitable answer for this: how do I implement multiple sequence keys commands, like in SF2's Hadouken (down, down+front, front - punch)?
Is there any tutorial I may have missed? Any tips/help?

Thanks in advance,

Marcelo
B
9
S
3
Posts: 40
Reputation: 780

Post » Tue Nov 25, 2014 5:01 pm

Hi @thealchemistbr - Let's take the "down, down+front, front, punch" example:

Set up a string global variable to store sequence of keys pressed - initial value "".

On key press "down" set variable to "down,"

On key press "down+front" if variable is already "down" then change to "down, down+front" else (whatever appropriate)

On key press "front" if variable is already "down, down+front" then change to "down, down+front, front" else (whatever appropriate)

On key press "punch" if variable is already "down, down+front, front" then do the SF2 Hadouken thing else (whatever appropriate)

If you have many such multi-key commands than you might want to plan a matrix of these before coding them up.

Hope that helps.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 5:16 pm

Sure it does. Just thinking - how would I properly determine is the first down should put the player to down animation or start the sequence? Maybe a tick-based flag?
B
9
S
3
Posts: 40
Reputation: 780

Post » Tue Nov 25, 2014 6:39 pm

You could try including a time element, like if they don't press the second key within so many ticks you just do the down animation and reset the variable to "".
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 11:54 pm

Will try that approach. Thanks a lot!
B
9
S
3
Posts: 40
Reputation: 780

Post » Wed Nov 26, 2014 12:11 am

No problem - let me know how you get on.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 5 guests