• 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!

Android virtual keys

B

B.Mejlvang

Guest
im having trouble with my virtual keyboard in my game.

it is meant to be be run on android.

this is the code i have in my virtual keboards a- key

global.a = virtual_key_add(20, 20, 30, 48,ord("A");
virtual_key_show(global.a)

my program prints my key presses to the screen but when i use my virtual keyboard it will print a blank space. if i set it to print the keycode instead it will print 0.
when i run it on pc and press a physical key, and then the virtual key, it will print the key that i pressed previously.

if i use this code

global.a = virtual_key_add(20, 20, 30, 48,vk_left;
virtual_key_show(global.a)

it will run the left key event so i cant see why it shouldn't work with ord("A")

can anybody help me with this because i fell like i have tried everything
 
B

B.Mejlvang

Guest
i just tried adding an event for the a key and that worked as well, so i think the problem is in this.

create event:

keyCodes = ds_list_create();
ds_list_add(keyCodes,"")
device_is_keypad_open()
word[0]="male"
word[1]="bird"
wordNr=random(array_length_1d(word))

global.bogstaver[0] = string_char_at(word[wordNr],1);
global.bogstaver[1] = string_char_at(word[wordNr],2);
global.bogstaver[2] = string_char_at(word[wordNr],3);
global.bogstaver[3] = string_char_at(word[wordNr],4);
antalBogstaver=array_length_1d(global.bogstaver)

image_speed=1


step event:

if(keyboard_check_pressed(vk_anykey))
{
ds_list_add(keyCodes, keyboard_lastchar)

}


draw event:

var i, s, p, j, hAfs, vAfs, keyNr, point, runde, tries;
p=0;
j=0;
hAfs=150;
keyNr=1;
point=0
var spacing = 0;
var n = 4;
var charWidth = 20; // Set to whatever...
var newlineMargin = charWidth*n;
vAfs=85;
runde=4

var drawX = 50; // Set to whatever...
var drawY = 80; // Set to whatever...
draw_set_font(font0)
draw_set_colour(c_green)


for(i = 1; i < ds_list_size(keyCodes); i++)
{
draw_text(drawX+(i*charWidth)-(spacing*newlineMargin),drawY+(spacing*20), keyCodes[| i]);
if i mod n == 0 and i != 0 then spacing++;
/*s = (ds_list_find_value(keyCodes, i));
draw_text(4+i*20, 20*p, s);*/


if i=runde{
if (ds_list_find_value(keyCodes, keyNr))==global.bogstaver[j]{
draw_sprite(spr_flueben,0,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1
point+=1
}
else{
draw_sprite(spr_flueben,1,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1

}
if (ds_list_find_value(keyCodes, keyNr))=global.bogstaver[j]{
draw_sprite(spr_flueben,0,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1
point+=1
}
else{
draw_sprite(spr_flueben,1,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1

}
if (ds_list_find_value(keyCodes, keyNr))=global.bogstaver[j]{
draw_sprite(spr_flueben,0,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1
point+=1
}
else{
draw_sprite(spr_flueben,1,hAfs,vAfs+p*20)
j+=1
hAfs+=20
keyNr+=1
}
if (ds_list_find_value(keyCodes, keyNr))=global.bogstaver[j]{
draw_sprite(spr_flueben,0,hAfs,vAfs+p*20)
j=0
p+=1
hAfs=150
keyNr+=1

point+=1
if point=4{
room_goto(room_win_4)
}
else{
point=0}
runde+=4
}
else{
draw_sprite(spr_flueben,1,hAfs,vAfs+p*20)
j=0
p+=1
hAfs=150
keyNr+=1
runde+=4
if point=4{
room_goto(room_win_4)
}
else{
point=0
}
}
}

}

if runde==44{
room_goto(room_lose_4)}
 
Top