如何在godot 里面 检测 手机触摸事件,在Godot 3.2.4版本下使用下面代码
var touch_pos = Vector2.ZERO # 触摸位置
var lift_up_pos = Vector2.ZERO # 抬手位置
func _input(event: InputEvent) -> void:
# 触摸按下
if event is InputEventScreenTouch:
touch_pos = event.position
# 拖拽
elif event is InputEventScreenDrag:
lift_up_pos = event.position
# 触摸抬起
elif event is InputEventMouseButton:
if touch_pos.distance_to(lift_up_pos) > 10:
printt(touch_pos.distance_to(lift_up_pos),
lift_up_pos, touch_pos
)
lift_up_pos = event.position
touch_pos = event.position