• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

keyboard_check_direct not working

F

Foxis

Guest
i did a code and it worked fine, the event was "f5 press" and then i switched it to created (Im really noob)
and this is my code


(the only thing i added was if keyboard_check_direct(vkf5)
and no errers when starting

if keyboard_check_direct(vk_f5)
{
if obj_sr1.sprite_index = spr_0{
obj_sr1.sprite_index = spr_1}

else if obj_sr1.sprite_index = spr_1{
obj_sr1.sprite_index = spr_2}

else if obj_sr1.sprite_index = spr_2{
obj_sr1.sprite_index = spr_3}

else if obj_sr1.sprite_index = spr_3{
obj_sr1.sprite_index = spr_4}

else if obj_sr1.sprite_index = spr_4{
obj_sr1.sprite_index = spr_5}

else if obj_sr1.sprite_index = spr_5{
obj_sr1.sprite_index = spr_6}

else if obj_sr1.sprite_index = spr_6{
obj_sr1.sprite_index = spr_7}

else if obj_sr1.sprite_index = spr_7{
obj_sr1.sprite_index = spr_8}

else if obj_sr1.sprite_index = spr_8{
obj_sr1.sprite_index = spr_9}

else if obj_sr1.sprite_index = spr_9{
obj_sr1.sprite_index = spr_0;

if obj_sr2.sprite_index = spr_0{
obj_sr2.sprite_index = spr_1}

else if obj_sr2.sprite_index = spr_1{
obj_sr2.sprite_index = spr_2}

else if obj_sr2.sprite_index = spr_2{
obj_sr2.sprite_index = spr_3}

else if obj_sr2.sprite_index = spr_3{
obj_sr2.sprite_index = spr_4}

else if obj_sr2.sprite_index = spr_4{
obj_sr2.sprite_index = spr_5}

else if obj_sr2.sprite_index = spr_5{
obj_sr2.sprite_index = spr_6}

else if obj_sr2.sprite_index = spr_6{
obj_sr2.sprite_index = spr_7}

else if obj_sr2.sprite_index = spr_7{
obj_sr2.sprite_index = spr_8}

else if obj_sr2.sprite_index = spr_8{
obj_sr2.sprite_index = spr_9}

else if obj_sr2.sprite_index = spr_9{
obj_sr2.sprite_index = spr_0}}

}
 

YoSniper

Member
I'm not sure what the difference is between keyboard_check and keyboard_check_direct, but I think the function you are looking for is keyboard_check_pressed

I'm guessing that by your code "not working" that the character is quickly cycling through its sprites. The modified code will change the sprite only when you press the key.
 
the event was "f5 press" and then i switched it to created (Im really noob)
Do you mean that you changed the event from being the F5 pressed event to the Create event? If so, then you will never be able to get this to work as it will only run this code when the object gets created once, and you aren't going to be able to hit F5 at the exact same time that the object is created. If you did put this in the Create event then you need to move it to the Step event instead so that it will be called every step of the event.
 

FrostyCat

Redemption Seeker
Why fix what wasn't broken to start with? Explain when it has become a sin to use the built-in keyboard events. This "I'm a big boy and I won't use built-in features" movement is getting out of hand in GM user circles.
 
F

Foxis

Guest
Why fix what wasn't broken to start with? Explain when it has become a sin to use the built-in keyboard events. This "I'm a big boy and I won't use built-in features" movement is getting out of hand in GM user circles.
on another thread i posted i asked how to get key inputs when the program is minimized, and i got an answer to use that. This "I'm a necessery person and i will not comment a necessery comment, i will just fill it with 💩💩💩💩" is getting out of hand.
but for real, dont assume things when you dont know anything, grow up.

Do you mean that you changed the event from being the F5 pressed event to the Create event? If so, then you will never be able to get this to work as it will only run this code when the object gets created once, and you aren't going to be able to hit F5 at the exact same time that the object is created. If you did put this in the Create event then you need to move it to the Step event instead so that it will be called every step of the event.
thanks i switched it to step.
 
B

Bayesian

Guest
Explain when it has become a sin to use the built-in keyboard events.
In this case based on his other thread Foxis wants to detect keys when the window is not in focus, so events don't suffice.
 
Top