multitouchArea is an Area2D that emits high-level press/drag signals from
both mouse and touch input. Unlike interactiveArea2D
(which is built for drag & drop with priority arbitration), multitouchArea is a
lightweight listener for "something was pressed/dragged here" β handy for a
canvas, a fullscreen input catcher, or drawing.
Attach the multitouchArea scene to a
Node and give it a CollisionShape2D.
To make it cover the whole screen, enable fullscreen: the collision shape is
resized to G.W Γ G.H and kept in sync on window resize.
@onready var area = $multitouchArea # with fullscreen = trueEach signal carries a normalised event = {position, pressed, index} (index
disambiguates fingers / buttons for multitouch):
| signal | when |
|---|---|
pressing(event) |
press started (mouse down / touch down) |
dragging(event) |
pointer moved while pressed |
pressed(event) |
released |
stopPressing(event) |
released (companion to pressed) |
longPress(latestPressEvent) |
held longer than longPressTime |
fullscreen: boolβ auto-fit the collision shape to the screenlongPressTime: int = 500β milliseconds beforelongPressfires
func _ready():
area.pressing.connect(_onPress)
area.dragging.connect(_onDrag)
area.longPress.connect(_onLongPress)
func _onPress(event):
G.log('pressed at', event.position)
func _onDrag(event):
draw_to(event.position)behaviours/rotation.gdβ attach to aTextureRectto spin it continuously; exposes a singlespeedexport (radians/second factor).