How to cancel one keyboard input when another input is held?

Just started using Construct 2? Post your questions here

Post » Thu Apr 09, 2015 6:51 pm

Basically, the player sprite can charge a jump left or right by holding down the left or right arrow keys. The problem I have is by holding down the right key and then pressing the left key, it interrupts the charging I was initiating with the right key. And vice versa. How would I go about avoiding this? Thanks
B
8
S
1
G
1
Posts: 34
Reputation: 473

Post » Thu Apr 09, 2015 7:45 pm

Create global variable 'state'
when right or left key is down --> set 'state' to 1
else --> set 'state' to 0
state=1 --> do a charging
charging is complete..
sub event: on release key left --> jump to left
sub event: on release key right --> jump to right
ImageImage
B
88
S
42
G
20
Posts: 720
Reputation: 19,723


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests