Android continuous touch position?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JorensM

I need to get the position of a touch continuously . When I use InputEventScreenTouch, it only gives position when the touch is pressed/released. When I use InputEventScreenDrag, it only gives position when it is dragged, but not when it is held in one place. My problem is that I can’t get position of touch while it is being held down in one place. Any ideas how to solve this?

:bust_in_silhouette: Reply From: decepticlown

InputEventScreenTouch is the one you want. As you said, each event has pressed and released. Once its pressed that means touch is active and it is active. Once touch is removed event is fired with same index id with “pressed” variable false. That means touch was active until now.

extends Node
var first_touch

func _input(event):
	if event is InputEventScreenTouch:
		if event.pressed :
			first_touch = event
			# Touch is pressed from now on
		if !event.pressed and event.index == first_touch.index:
			first_touch = null
			# first touch was just removed.