device_mouse_x(device);
Argument | Description |
---|---|
device | The device (from 0 - 4) that is being checked. |
Returns: Real
This function returns x position of the device. If you are
running this on a the HTML5 or PC and Mac modules then this value
is updated constantly, as long as the device (usually a mouse) is
plugged in, however for mobile devices, this will only be updated
while the screen is being touched.
if device_mouse_check_button(0, mb_left)
{
if device_mouse_x(0) > x-32 &&
device_mouse_x(0) < x+32
{
pressed = true;
}
else
{
pressed = false;
}
}
The above code checks to see if the device is being pressed and if so it then polls the device x position to see if it is within the parameters. If it is it sets the variable "pressed" to true, other wise it sets it to false.