mirror of
https://github.com/Relintai/pandemonium_demo_projects.git
synced 2024-12-21 13:56:50 +01:00
21 lines
769 B
GDScript3
21 lines
769 B
GDScript3
|
extends Node
|
||
|
# This will track the position of every pointer in its public `state` property, which is a
|
||
|
# Dictionary, in which each key is a pointer index (integer) and each value its position (Vector2).
|
||
|
# It works by listening to input events not handled by other means.
|
||
|
# It also remaps the pointer indices coming from the OS to the lowest available to be friendlier.
|
||
|
# It can be conveniently setup as a singleton.
|
||
|
|
||
|
var state = {}
|
||
|
|
||
|
func _unhandled_input(event):
|
||
|
if event is InputEventScreenTouch:
|
||
|
if event.pressed: # Down.
|
||
|
state[event.index] = event.position
|
||
|
else: # Up.
|
||
|
state.erase(event.index)
|
||
|
get_tree().set_input_as_handled()
|
||
|
|
||
|
elif event is InputEventScreenDrag: # Movement.
|
||
|
state[event.index] = event.position
|
||
|
get_tree().set_input_as_handled()
|