Virtual Keys [SOLVED]

M

mjmiller1824

Guest
Without seeing your code the work around would be press [set status] (set alarm) press[set status2]( reset alarm) press [set status 3]. So I would do something like:

keyboard_press: add_motion (count 10 frames)[press1],
keyboard_press before alarm: add_motion(count 10 frames)[press2]
keyboard_press before alarm: convert to flying.
 

Neptune

Member
So, just to clarify my issue, I do not see how this could be a coding issue. My code has worked great for quite a long time now -- that being said, I believe there must be an intricate rule being broken in the relationship between keyboard_check_press and keyboard_check_pressed, when it comes to virtual keys.

I guess, I'm just looking for more information about virtual keys; I think that is the best way to fix the problem I'm having.

The GM:S Virtual Key manual information is straightforward and short: "This function enables you to map "touches" of a screen area to keyboard events. This means that once you have assigned an area to a virtual key, all touches on that area will trigger the keyboard event corresponding to the key you have mapped to the area."

 
W

Wraithious

Guest
I don't know how you have set up your code but I wouldn't use keyboard_check_pressed at all, this is what I would do,
create event of your virtual key object:
Code:
time_me=0;
jump=1;
w_button=0;
in the step event of your virtual key object you could have:
Code:
if time_me>0 time_me --;//runs the timer for the player to execute the 3 button press
if  (w_button = 3 && !(keyboard_check(ord('W'))))//resets the variables if the player lets go of w key to stop flying
{
jump=1;
w_button=0;
jumping_obj.y=floor_obj.y - jumping_obj.sprite_height;//whatever your return to floor code is execute it here
}
if(keyboard_check(ord('W')) && jump=1)//set up the 3 button press
{
if(jump=1 && w_button=0)//first jump
{
w_button=1;
time_me=20;//set the timer here
jumping_obj.y -=20;//whatever your jumping objects jump code is, execute it here
jump=0;
alarm[0]=3;
}
if(jump=1 && w_button=1 && time_me>0)//second jump
{
w_button=2;
jumping_obj.y -=20;//whatever your jumping objects jump code is, execute it here
jump=0;
alarm[0]=3;
}
if(jump=1 && w_button=2 && time_me>0)//fly around, don't set alarm[0] this time, when you release w key it will reset
{
w_button=3;
jumping_obj.y=floor_obj.y-(jumping_obj.sprite_height-20);//whatever your jumping objects flying code is, execute it here
jump=0;
}
}
alarm[0]:
Code:
jump=1;
 
Last edited by a moderator:

Neptune

Member
Thanks for reply @Wraithious !
Unfortunately, what I'm trying to say is, my player-object code works fine.
However I have "on-screen" GUI controls for Android phone users (it is an Android app), and these work fine, with one exception.

The third press of the "on-screen" jump key doesn't register, and therefore flight is not achieved.
However, if I manually press jump 3 times on my keyboard, everything works fine: jump, jump, fly!

By the definition in the manual, there shouldn't be a difference -- using virtual keys should translate directly to actual keyboard-presses, however its just not... :(
 
Last edited:
W

Wraithious

Guest
What i meant is not using keyboard_check_pressed and just use keyboard_check instead and use some variables, an alarm and timer like in my example, it should work. Android is different than windows. also if you are testing on both windows and android make sure your windows keyboard codes are isolated from the android virtual button codes because they will interfere, i set a global variable at game start to determine the os and use it to seperate my keyboard/virtual controls
 

Neptune

Member
I see!
I took some of your advice, and was able to isolate the issue, and fix it up!
Thanks for taking the time to help out -- I appreciate it!
 
Top