Legacy GM Problem with Multitouch on Mobile

C

Chad

Guest
So Im working on converting my project from PC to Android and it needs to be done by the 14th.. My problem right now is that I can't run and shoot at the same time. I have two objects on the left side of the screen that follow my view that i use for running. I then have 4 other objects (kinda like a dpad) that i use for shooting, they are all on the right side of the screenIHeres the running code:
Code:
/// Click

click = device_mouse_check_button(0,mb_left) || device_mouse_check_button(1,mb_left);


if (click)
{
    with (instance_position(mouse_x,mouse_y,obj_left_control))
    {
        global.is_active_left = true;
    }
}
else
{
    global.is_active_left = false;
}
Here is the Shooting buttons code:
Code:
/// Click

click = device_mouse_check_button(0,mb_left) || device_mouse_check_button(1,mb_left);


if (click)
{
    with (instance_position(mouse_x,mouse_y,obj_shoot_left))
    {
        global.shoot_left = true;
    }
}
else
{
    global.shoot_left = false;
}

x = view_xview[0] + wi
y = view_yview[0] + hi
All the code for all the buttons are very similar. I handle the movement and actual shooting in the same place as the PCs inputs. Please help!
 

Lite

Member
Limit the movement controls with another if statement saying if one of the shooting button objects are pressed don't move with this device mouse. So basically say if either of the device mouse buttons are pressed AND position meeting of the device mouse is not one of the buttons, then it's okay to move.
 

FrostyCat

Redemption Seeker
If you find it sensible to use device functions to check for taps, why don't you find it sensible to use their coordinate functions as well? You have more than one coordinate to check now, mouse_x and mouse_y make no sense here.
Code:
var tap_found = false;
for (var finger = 0; finger <= 4 && !tap_found; finger++) {
  if (device_mouse_check_button(finger, mb_left) && position_meeting(device_mouse_x(finger), device_mouse_y(finger), obj_shoot_left)) {
      global.is_active_left = true;
      tap_found = true;
    }
  }
}
if (!tap_found) {
  global.is_active_left = false;
}
And have you looked at virtual keys? They do exactly what you described with a simpler interface.
 
Top