Mouse and touch

Conditions and actions to handle either the mouse or touches on touchscreen. By default, conditions related to the mouse will also handle the touches - so that it's easier to handle both in your game. You can disable this behavior if you want to handle them separately in different events. Read more explanations about it.

Actions

Hide the cursor
Hide the cursor.

Show the cursor
Show the cursor.

De/activate moving the mouse cursor with touches
When activated, any touch made on a touchscreen will also move the mouse cursor. When deactivated, mouse and touch positions will be completely independent.
By default, this is activated so that you can simply use the mouse conditions to also support touchscreens. If you want to have multitouch and differentiate mouse movement and touches, just deactivate it with this action.

Conditions

The mouse wheel is scrolling down
Check if the mouse wheel is scrolling down. Use MouseWheelDelta expression if you want to know the amount that was scrolled.

The mouse wheel is scrolling up
Check if the mouse wheel is scrolling up. Use MouseWheelDelta expression if you want to know the amount that was scrolled.

Mouse button pressed or touch held
Check if the specified mouse button is pressed or if a touch is in contact with the screen.

Mouse button released
Check if the specified mouse button was released.

Cursor X position
Compare the X position of the cursor or of a touch.

Cursor Y position
Compare the Y position of the cursor or of a touch.

A touch has ended
Check if a touch has ended. The touch identifier can be accessed using LastEndedTouchId().
As more than one touch can be ended, this condition is only true once for each touch: the next time you use it, it will be for a new touch, or it will return false if no more touches have just ended.

A new touch has started
Check if a touch has started. The touch identifier can be accessed using LastTouchId().
As more than one touch can be started, this condition is only true once for each touch: the next time you use it, it will be for a new touch, or it will return false if no more touches have just started.

Touch X position
Compare the X position of a specific touch.

Touch Y position
Compare the Y position of a specific touch.

Expressions

Expression Description
LastEndedTouchId() Identifier of the last ended touch
LastTouchId() Identifier of the last touch
MouseWheelDelta() Mouse wheel displacement
MouseX(layer, number) Return the X position of the cursor or of a touch.
layer Layer (base layer if empty) Optional.
number Camera number (default : 0) Optional.
MouseY(layer, number) Return the Y position of the cursor or of a touch.
layer Layer (base layer if empty) Optional.
number Camera number (default : 0) Optional.
TouchX(number, layer, number) Return the X position of a specific touch.
number Touch identifier
layer Layer (base layer if empty) Optional.
number Camera number (default : 0) Optional.
TouchY(number, layer, number) Return the Y position of a specific touch.
number Touch identifier
layer Layer (base layer if empty) Optional.
number Camera number (default : 0) Optional.

This page is an auto-generated reference page about the Mouse and touch feature of GDevelop, the open-source, cross-platform game engine designed for everyone. Learn more about all GDevelop features here.