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

Legacy GM multitouch not working

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:
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);
look stick:

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);
hope someone can help me.
 

The-any-Key

Member
Loop each device mouse check and check for button press.
When a press is detected check in what area it is in. Ex in left or right side.
Save the index for the control it should use ex stick or look.
Use the index in the controller until finger is lifted.
When lifted reset the saved index so the controller is deactivated and waiting for a new index.
 
Y

Yvalson

Guest
Loop each device mouse check and check for button press.
When a press is detected check in what area it is in. Ex in left or right side.
Save the index for the control it should use ex stick or look.
Use the index in the controller until finger is lifted.
When lifted reset the saved index so the controller is deactivated and waiting for a new index.
I don't know what you mean by that but the problem with my code is related to point_in_rectangle not working
for some reason. here is the new code since a changed some stuff.

Code:
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) or point_in_rectangle(device_mouse_x(1),device_mouse_y(1),view_xview+view_wview/2, view_hview, view_xview+view_wview, view_yview)){
if(device_mouse_check_button(0, mb_left)){
    self.x = mouse_x
    self.y = mouse_y
}
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);
and second stick
Code:
if(point_in_rectangle(device_mouse_x(0),device_mouse_y(0), view_xview, view_hview, view_xview+view_wview/2, view_yview) or point_in_rectangle(device_mouse_x(1),device_mouse_y(1), view_xview, view_hview, view_xview+view_wview/2, view_yview)){
if(device_mouse_check_button(0, mb_left)){
    self.x = mouse_x
    self.y = mouse_y
}
else if(device_mouse_check_button(1, 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);
when I draw the rectangles with draw_rectangle everything works fine (this is in Draw or Draw GUI event) yet when I try point_in_rectangle (in my project those are in the step event) the arent working
 

The-any-Key

Member
You need to change mouse_x and y to device_mouse_x(0) and (1).
mouse_x is the same as device_mouse_x(0)

But it will still not work because the code assume only one finger is pressed. You need to create a better logic like the one in my previous post.
 
Y

Yvalson

Guest
You need to change mouse_x and y to device_mouse_x(0) and (1).
mouse_x is the same as device_mouse_x(0)

But it will still not work because the code assume only one finger is pressed. You need to create a better logic like the one in my previous post.
yeah I already fixed the entire code in another post but thanks anyway
 
Top