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

GameMaker Touch control joysticks

S

Slothagami

Guest
I'm making a local co-op game for two players, this is my first time adding touch controls for a game (it's not for a phone, my computer has a touch screen)

I was making a joystick in screen for each player using the dragging event, and only one of the joysticks work at a time, is there a solution to this?

here is my code:
GML:
// o_touchcontrol draw event
//draw circle for the joystidk limits and smaller one for player input place
draw_set_alpha(0.5);
draw_set_color(color);
draw_circle(x, y, touch_radius, true);
draw_circle(touchx, touchy, touch_radius / 4 - (joystick * 4), false);
draw_circle(button_x, button_y, touch_radius / 4 - (button * 4), false);
draw_set_color(c_white);
draw_set_alpha(1);
GML:
// o_touchcontrol drag event
if point_distance(x, y, event_data[? "posX"], event_data[? "posY"]) <= touch_radius {
    touchx = event_data[? "posX"];
    touchy = event_data[? "posY"];
    joystick = true;
}
GML:
// o_touchcontrol drag end event
touchx = x;
touchy = y;

joystick = false;
button = false
thanks in advance!
 
Last edited by a moderator:

kburkhart84

Firehammer Games
1. The code only shows where you are drawing stuff....it doesn't actually show where you are checking the touches. If you are using the drag event, I'm not sure if it will work for multiple touches in the first place, even if you have multiple objects.

2. Are you sure that your screen supports multiple touches...some don't.

3. Have you tried manually checking for the touches instead of using the drag event? The multitouch stuff primarily works on mobile, so on the regular desktop I'm not sure if it works or not. Maybe someone here will know better than I and would comment.
 
S

Slothagami

Guest
1. The code only shows where you are drawing stuff....it doesn't actually show where you are checking the touches. If you are using the drag event, I'm not sure if it will work for multiple touches in the first place, even if you have multiple objects.
sorry about that I pasted the wrong code! It should be correct now.
How do I check if my screen supports multi touch?
 
Last edited by a moderator:

kburkhart84

Firehammer Games
How do I check if my screen supports multi touch?
You need to look up the specs on your screen.

About using the gestures event stuff...I'm not 100% sure if those support multiple touches at the same time either to be honest. You should maybe investigate that. Someone here who uses them may also be able to verify.
 

samspade

Member
Gesture events are multitouch by default
You need to look up the specs on your screen.

About using the gestures event stuff...I'm not 100% sure if those support multiple touches at the same time either to be honest. You should maybe investigate that. Someone here who uses them may also be able to verify.
They do. At least as far as I've tested them on an android tablet.
 

kburkhart84

Firehammer Games
Gesture events are multitouch by default


They do. At least as far as I've tested them on an android tablet.
Good to know, then now it seems either there is something wrong with the code, the screen doesn't do multitouch, or the gesture events on Windows don't support multitouch.
 

samspade

Member
All the gesture events return event_data (a ds map) that I believe records the touch detected under the key "touch". So an easy debug would be to create some global gesture events use show_debug_message or the debugger to log and/or print the touch detected by the gesture event. That would tell you a fair amount about whether they work and how many touches they'll detect.
 
Top