Double-press buttons

Get help using Construct 2

Post » Tue Jan 29, 2013 3:20 pm

Did a search and could only find construct classic bits and pieces which weren't entirely relevant.

I have my character with the required animations:

Single punch
Double punch

Pressing the A key triggers the single punch animation.
I can't work out properly how to have the double punch animation trigger instead if the A key is pressed twice within a short space of time (200-300ms for example)

Thanks ahead for any help :)


B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Tue Jan 29, 2013 3:33 pm

You probably have two variables on your player. One called "DoublePunch" and another one called "DoublePunch_Toggled" or something like that.
So,

When A is pressed:   (Punch)
                               Set DoublePunch to 1

When A is pressed     Set DoublePunch_Activated to 1
DoublePunch is = 1

When A is Pressed
DoublePunch_Toggled = 1 (Double Punch)
                                        Set DoublePunch to 0
                                        Set DoublePunch_Toggled to 0

Now you can Double Punch, but you can also do it after 200-300 ms.
So, you need to add a "Wait" action when A is pressed:

When A is pressed: (Punch)
DoublePunch = 1      Wait 200/300 ms
                                Set DoublePunch_Activated to 0
                                Set DoublePunch to 0

I am not sure if this will work, try it.
And maybe upload a .capx, if it doesnt work!

-CX05CX052013-01-29 15:36:22
B
5
Posts: 55
Reputation: 585

Post » Tue Jan 29, 2013 3:34 pm

Cheers, I'll give it a try now :)
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Tue Jan 29, 2013 3:37 pm

Super, and please upload a .capx so i can take a look at it, if it doesn't work:)
B
5
Posts: 55
Reputation: 585

Post » Tue Jan 29, 2013 3:49 pm

Didn't work,

Here is the file
https://dl.dropbox.com/u/123274811/testing.capx

The events in particular are at bottom of event sheet.

Thanks
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Tue Jan 29, 2013 4:19 pm

If anyone else has a suggestion, please don't hesitate to comment :)
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Tue Jan 29, 2013 4:54 pm

Not sure if wait will work as that code won't accept any other input during the wait if I am not off in my thinking. That is the point of the wait.

I could be wrong though.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Tue Jan 29, 2013 4:56 pm

The wait command didn't work, I thought it ignored input too
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Tue Jan 29, 2013 8:16 pm

Damn, i'll take a deeper look tommorow when i get home :P
B
5
Posts: 55
Reputation: 585

Post » Tue Apr 02, 2013 9:48 pm

Hello. First post. Love Construct2.
Also in need of similar method. If player press x only once, block. If player double-press x, then dodge. Sounds easy. Couldn't make it work. Timers and stuff getting messy.
Sound something so intuitive that there should be a topic or even a behaviour support for it. Also double tap for touchscreen.
Best Regards.
                            



B
16
S
4
G
1
Posts: 332
Reputation: 3,016

Next

Return to How do I....?

Who is online

Users browsing this forum: Kagubro and 35 guests