Y
Yvalson
Guest
so i'm making a game in which the player can move using 1 on screen stick and look around with another one.
however when using device_mouse_button this gives problems due the first touch on the screen always being device_mouse(0)
so whenever I touched the left side of the screen first my player would start moving because the movement was assigned to the first finger
I tried to change it with using point_in_rectangle but I can't get it to work.
here is the code for the sticks. the code for both of them is pretty similar.
the outcommented text is code I first used but didn't work so feel free to uncomment it if it's usefull
movement stick:
look stick:
hope someone can help me.
however when using device_mouse_button this gives problems due the first touch on the screen always being device_mouse(0)
so whenever I touched the left side of the screen first my player would start moving because the movement was assigned to the first finger
I tried to change it with using point_in_rectangle but I can't get it to work.
here is the code for the sticks. the code for both of them is pretty similar.
the outcommented text is code I first used but didn't work so feel free to uncomment it if it's usefull
movement stick:
Code:
//if (device_mouse_check_button(0, mb_left) or device_mouse_check_button(1, mb_left)) {
if (point_in_rectangle(device_mouse_x(0), device_mouse_y(0), view_xview+view_wview/2, view_hview, view_xview+view_wview, view_yview)) {
show_message("Water");
}
if (point_in_rectangle(device_mouse_x(1), device_mouse_y(1), view_xview+view_wview/2, view_hview, view_xview+view_wview, view_yview)) {
show_message("Lollies");
}
//}
//if(device_mouse_check_button(0, mb_left)){
//self.x = mouse_x
//self.y = mouse_y
//}
x = clamp(x, Obj_OuterRing_Move.x - 96, Obj_OuterRing_Move.x + 96);
y = clamp(y, Obj_OuterRing_Move.y - 96, Obj_OuterRing_Move.y + 96);
Code:
//if (device_mouse_check_button(i, mb_left)) {
if (point_in_rectangle(device_mouse_x(0), device_mouse_y(0), view_xview, view_hview, view_xview+view_wview/2, view_yview)) {
show_message("Cactus");
}
if (point_in_rectangle(device_mouse_x(1), device_mouse_y(1), view_xview, view_hview, view_xview+view_wview/2, view_yview)) {
show_message("Tering");
}
//}
//if(device_mouse_check_button(1, mb_left)){
//self.x = mouse_x
//self.y = mouse_y
//}
x = clamp(x, Obj_OuterRing_Aim.x - 96, Obj_OuterRing_Aim.x + 96);
y = clamp(y, Obj_OuterRing_Aim.y - 96, Obj_OuterRing_Aim.y + 96);