• 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 Multiple "mouse clicks" for mobile game

YoSniper

Member
Hello everyone.

So I am very green when it comes to developing a game for a mobile device.

I already have a game that is mostly done, but it would only work on a PC, with either a keyboard or a connected game controller.

To create a mobile version, what I have thought to do would be to create icons of buttons on the sides of the screen, and if the mobile device detects a tap or a hold within any of those regions represented by the icons, that would count as a game input.

The problem is that often times, the game may expect more than one input at a time (such as attacking while running.) But I believe I'm limited to a single mouse input even though the user may have two or more fingers pressing the screen.

How do I detect for multiple touchscreen presses? Does it involve functions similar to mouse_check_button and keywords like mb_left?

The manual does not make this clear from what I searched.
 

rIKmAN

Member
The manual does not make this clear from what I searched.
What did you search?
The manual page for Mouse Input says "Mouse input is accepted on all platforms (on mobile devices it is accepted as a single touch. If you need to use multi-touch, you should be using the device specific functions)"

Following that multi-touch link leads you to the section for the device_* functions, where pretty much every one of them explains on their function page:
Now, the device refers to the mouse number, which can be from 0 to 4 and this event is triggered when the touch screen of a mobile device is touched, so in this way you can test for up to 5 different screen touches (or mouse devices).
So when you use one of the device_* functions, you increment the device argument that you pass into the functions to check for each subsequent finger used in multi-touch on a touch screen.

So something like the following in a Draw Event will draw a circle at the point each finger touches the screen.
Code:
for(var i=0; i<5; i++)
{    
    if(device_mouse_check_button(i, mb_left))
    {        
        draw_circle(device_mouse_x(i), device_mouse_y(i), 50, false);
    }
}
 
Top