Testing for key pressed

Get help using Construct 2

Post » Thu Jan 31, 2013 9:03 am

There are some similar forum posts out there that have somewhat clarified part of my issue here - I now understand the difference between On Key Down and On Key Pressed. The latter waits for the release of the key.

MY present issue is that I simply want to have an Action take place when the Event tests that a key has been pressed at all, regardless if the key is held down or released...or not. Just, was it pressed.

My scenario is that I have a character who will throw a punch upon the K key being pressed. The Action that ought to follow is that the Punch animation will play...from start to finish, all six frames. However, whether I use either On Key Down or On Key Pressed, the animation is immediately interrupted when I let go of the key.

(I've tried setting up a work-around - and almost got it "perfected" - but it's too lengthy to try to explain.)

So, ultimately, what I want to happen is this...
1) I tap the K key and quickly release...
(SIDE NOTE: Presently, pending a solution, I can hold it down, whether by O.K. Down or O.K. Pressed, and the animation repeats until I release the key.)
2) ...The punch then plays through a full sequence once regardless of the current true/false of the K key press in subsequent frames.

I've made sure the Loop is set to No on the animation sequence. I've also tested On Key Released. None of them work for my desired result.

Thank you for your help!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Thu Jan 31, 2013 9:08 am

Could you post .capx or image of the problematic events?
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Thu Jan 31, 2013 3:31 pm

What you want is 'on key pressed' but you probably have another event changing the animation when you're not pressing the key.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Thu Jan 31, 2013 9:33 pm

@vee41 - *sarcastically to myself* Now why didn't I think of that? *facepalm*

@ramones - Just before I checked the replies here, I was talking it over with my development partner, and that very fact dawned on me. Lo-and-behold, I had another event telling the running animation to reset to an idle pose after the release of - get this - ANY key. *MORE facepalm*

Thank you BOTH for your prompt replies and willingness to help.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Thu Jan 31, 2013 10:11 pm

@Rhindon - i thought i replied to you here haha, here is a capx with hopefully what you want to accomplish:

https://www.dropbox.com/s/t65ippgm1sic8u3/animationcontrol.capx
B
14
S
6
G
2
Posts: 136
Reputation: 3,210

Post » Thu Jan 31, 2013 10:23 pm

@wretchedshark - SIR! I think the missing piece is definitely the On any animation finished. Thank you, once again! :D

On line 4, I disabled both of the Keyboard S/D is NOT down Events and that didn't seem to have any effect on the outcome of the animations. If I think on it long enough, it'll probably dawn on me - hopefully - but what precisely are those two conditions for in light of the whole project?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Fri Feb 01, 2013 1:28 am

@Rhindon - it's ma'am! :]

they filter the "on any key pressed" down further to which key is being pressed, i didn't test it with "is down" instead of it. so on s pressed you get the punching animation and on d you get the kicking animation (which in that capx is just a bunch of faces).
B
14
S
6
G
2
Posts: 136
Reputation: 3,210


Return to How do I....?

Who is online

Users browsing this forum: Colorfish, MarkThomas, onzephyr and 30 guests