S
Sahibjot Cheema
Guest
I've already created dashing, I just wanted to know if anyone knows how to detect if right arrow or left arrow as been pressed twice in a short amount of time. Thanks
I created this but theirs a bug. You can move to one direction for a while then let go and it will register as dash but I only want it to dash when you press the key twice fast. Is their a way to detect when a button is pressed but it can only be detected the first time?You can set a timer to zero on key release. Ensure it counts up per step, and every time a key is pressed check if that timer is under 30 or so, which would indicate a double tap.
I don't think keyboard_check_press() exists. It doesn't register in GM and I can't find it online either. Btw I found out keyboard_check_pressed() does what you thought keyboard_check_press() does. I just found this out and everything works perfectly. Wish I found this out sooner. Thx thoughYep, use keyboard_check_press() will run code the first step it's pressed only.
keyboard_check_pressed() will run code for every step it's being pressed.
Whoops, sorry, wrote this fast on a phone. keyboard_check_press was a mistake, I meant to write keyboard_check_pressed. The context sensitive help should of showed only a few options anyway when you started typing it. Glad you sorted it out.I don't think keyboard_check_press() exists.
I am trying to use this for running: first the keyboard_check_pressed will set the timer and if I press the same key again and timer is on, I can run. The problem is that the time is still counting and as soon as it's off, it stops my running session.I don't think keyboard_check_press() exists. It doesn't register in GM and I can't find it online either. Btw I found out keyboard_check_pressed() does what you thought keyboard_check_press() does. I just found this out and everything works perfectly. Wish I found this out sooner. Thx though
Edit: I think you were trying to say this, "With this function you can check to see if a key has been pressed or not. Unlike the keyboard_check function, this function will only run once for every time the key is pressed down, so for it to trigger again, the key must be first released and then pressed again." It's from the GM wiki.
// set Timer for running
if (right_run_released) or (left_run_released) {
alarm[0] = 5;
}
// check left or right run and enable it
if alarm[0] >= 0 {
if right_run_pressed or left_run_pressed {
ableToRun = true;
}
}
// when running, double speed
if ableToRun == true {
maxSpeed = 10;
sprite_index = sPlayerRun;
if left_run_released or right_run_released {
ableToRun = false;
maxSpeed = 5;
}
}