+1 vote

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 ?

in Engine by (506 points)

1 Answer

+2 votes
Best answer

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).

by (27,664 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.