How to detect a screen touch continuously ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DriNeo
:warning: Old Version Published before Godot 3 was released.

In this code “ScreenTouch” is printed only once no matter the touch duration.

   func _input(ev):
     Event = make_input_local(ev)
     if (Event.type == InputEvent.SCREEN_TOUCH):
       if Event.pressed:
        increaseJumpForce()  # as an example if you want to make a runner on mobile.
        print( "ScreenTouch")

Have you some solution without using a button for this ?

:bust_in_silhouette: Reply From: Zylann

With this code you know already when a touch begins and a touch ends. If you want to continuously do something while the touch is pressed, you can store the state of the touch in a variable, and check that variable in _process() every frame, or use a Tween.

Also note that there can be more than one touch, you don’t know how many there can be (but they have an indexin the event so you can differenciate them).