Detecting a key hasn't been pressed

Get help using Construct 2

Post » Fri Apr 12, 2013 10:23 pm

I'm making a very simple arm-wrestling minigame as part of something larger and I've got it working fairly well. It's just a case of speed-tapping the space bar to win. The opponents score increases all the time but I'd like for it to increase much faster if the space bar hasn't been touched for a couple of seconds. What the simplest way of doing this (essentially, detecting that a key hasn't been pressed for x amount of time)?else2013-04-12 22:24:08
B
5
S
1
Posts: 52
Reputation: 640

Post » Fri Apr 12, 2013 10:36 pm

Run an event that, every tick, increases a variable (let's call it spaceTimer) by 60*dt.

When your player presses the spacebar, set spaceTimer to 0.

Then, depending on what your other events look like, check if spaceTimer > 60 or whatever amount of time you want, and if it is then increase the opponent's score by an increased amount. Or increase the score by a factor of spaceTimer, if you want it to be non-linear.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Fri Apr 12, 2013 10:42 pm

Thanks so much! I feel a bit silly now for failing to see that - I actually used a similar timer for something else yesterday...

These forums are great for a beginner like me. I really appreciate such helpful and prompt feedback.
B
5
S
1
Posts: 52
Reputation: 640


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, Braus, Kagubro, Mirlas, zeneizel and 20 guests