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
2
G
1
Posts: 34
Reputation: 623

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
101
S
45
G
22
Posts: 772
Reputation: 21,468


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests