Skip to content

Handle mouse and touch events

Some objects and behaviors make mouse and multitouch easier to handle for specific cases:

For more specific cases, mouse and touches events can be accessed directly.

Handle clicks and taps on objects

"The cursor/touch is on an object" condition checks if the mouse cursor or a screen touch is over an object.

This condition can be used with "Mouse button pressed" or "Mouse button released" to check if the object is clicked or taped.

The expressions CursorX and CursorY give the cursor position in the scene. For instance, it can be used to create an explosion effect exactly at the cursor or touch location.

Tip

See it in action! 🎮

Open this example online

Handle manually multi-touch gestures (advanced)

When only one touch is done at the same times, the mouse events can be used to keep things simple. Indeed, by default touch events are mirrored by mouse events. This can be disabled with the action “De/activate moving the mouse cursor with touches” when handling both multi-touch and mouse events to avoid echo.

Multiple touches can happen at the same time. The touch identifier must be used to tell them apart. It can be done by following these steps:

  • At the start of a touch, the touch identifier can be get with the StartedTouchId(Number) expression.

  • When the touch moves, the touch identifier is needed to make sure to follow the right touch. A variable can be used to ensure this.

Tip

See it in action! 🎮

Open this example online

Reference

All actions, conditions and expressions are listed in mouse and touch reference page.