C
Cdiddysir
Guest
So I am trying to make a mobile game, however I am having trouble with the touch controls. I have an on screen analog stick on the left side of the screen.
Here's the input code for that.
And i have virtual buttons on the right of the screen, here's the code for that.
For some reason, no matter what I do, or what device I set the buttons to, I can't use the virtual stick and the virtual button at the same time. I would have to stop my character first and then use the virtual button for it to register. It works on my PC just fine, but when I test it on my android it's like that. Any help would be appreciated.
Here's the input code for that.
Code:
// create event
/// @description Initialize Virtual Stick
//gui scale
scale = ob_game.window_scale;
//change to customize stick
max_displacement = 24; //how far the stick can move from center position
stick_radius = 16; //size of area user can touch to move
//do not change
interacting = false;
stick_x = x;
stick_y = y;
input_h = 0; //used to store the current input by the user between -1.0 and 1.0
input_v = 0;
//step event
var gui_mouse_x = device_mouse_x_to_gui(0);
var gui_mouse_y = device_mouse_y_to_gui(0);
if(device_mouse_check_button(0, mb_left))
{
if(point_distance(x * scale, y * scale, gui_mouse_x, gui_mouse_y) <= max_displacement * scale)
{
interacting = true;
}
}
else if(!device_mouse_check_button(0, mb_left))
{
interacting = false;
}
And i have virtual buttons on the right of the screen, here's the code for that.
Code:
// create event
/// @description Initialize Virtual Button
//gui scale
scale = ob_game.window_scale;
sprite = sp_button;
active = false;
text = "";
//step event
var gui_mouse_x = device_mouse_x_to_gui(0);
var gui_mouse_y = device_mouse_y_to_gui(0);
if(device_mouse_check_button_pressed(0, mb_right))
{
var spw, sph, x1, x2, y1, y2;
spw = sprite_get_width(sprite);
sph = sprite_get_height(sprite);
x1 = (x - (spw / 2)) * scale;
x2 = (x + (spw / 2)) * scale;
y1 = (y - (sph / 2)) * scale;
y2 = (y + (sph / 2)) * scale;
if(point_in_rectangle(gui_mouse_x, gui_mouse_y, x1, y1, x2, y2))
{
active = true;
}
}
else
{
active = false;
}