Game Maker Studio: (Part 2) How to Create Virtual Keys for Android?
Visit my MC GAMES site: https://mcolverdesigns.itch.io
Paypal Donate: http://bit.do/fkPAb
GMS File: https://bit.ly/38cworh
Resources:
GUI Location: https://bit.ly/37ffQNM
GUI Size: https://bit.ly/2tNxZos
Virtual Key Add: https://bit.ly/2SdPcR2
(Note:) Don't need to use cross hairs on buttons, better if you don't, so its easier to press on buttons.
(Note:) Virtual Key Add: I used Room Start in the Event area, over using Create, because if you go to the next room or pause game, the virtual keys will be destroyed, could be a glitch, not sure why they would be destroyed, after moving to another room. Room Start, makes virtual keys stay in room, and not be destroyed, when moving to the next room or pause game. If you are planning to switch two buttons.
(Note:) Say if you have person kicking on the right, you need a button for the right kick, and you will need a button for the left kick, but only make "one virtual key for both buttons". So, in both buttons you would have a virtual key, but its going to be named the same, example kickkey is the name for the virtual key, but the name kickkey would be used for both buttons for the kick, "do not make a second name for a virtual key for the other button", because then, the buttons are not going to work correctly when he kicks. The reason you only need one virtual key for both right and left kick buttons is because, you already assign it a keyboard key, say "vk_enter" for left and right kick. The virtual key can tell when you are moving in a different direction and knows which way you need to kick.
obj_right, same applies for other buttons, just change out coordinates, and virtual key add name events, example "rkey".
Events:
Room Start, Go to Add Event, then Other, then Room Start
Actions:
rkey = virtual_key_add(1040,2700,400,400, vk_right);
//virtual_key_show(rkey);
Events:
Draw
Actions:
draw_sprite(sprite_index,image_index,view_xview[0]+800,view_yview[0]+1472);
Events:
Draw GUI
Actions:
display_set_gui_size(view_wview[0]+800,view_hview[0]+1472);
obj_pause
Events:
Step
Actions:
x=view_xview[0]+2700
y=view_yview[0]+50
Events:
Left Pressed, for Mouse
Actions:
global.my_room = room
room_persistent=true
room_goto(room1)
Events:
Draw
Actions:
draw_sprite(sprite_index,image_index,view_xview[0]+2700,view_yview[0]+50);
obj_back
Events:
Step
Actions:
x=view_xview[0]+2700
y=view_yview[0]+50
Events:
Left Pressed, for Mouse
Actions:
room_goto(global.my_room)
Events:
Draw
Actions:
draw_sprite(sprite_index,image_index,view_xview[0]+2700,view_yview[0]+50);
obj_exit, backspace would be the back key on you're device.
Events:
Step
Actions:
if(keyboard_check_pressed(vk_backspace)){game_end();}