0 votes

My input detector looks like this:

func _input(event):
    if event is InputEventScreenDrag:
        if event.speed.y < -10:
            emit_signal('up')
        elif event.speed.y > 10:
            emit_signal('down')
        return
    elif event is InputEventScreenTouch:
        if event.pressed:
            if event.position.x < get_node("../ship").get_viewport_rect().size.x/2:
                emit_signal('touched', "left")
            else:
                emit_signal('touched', "right")
            return

The main issue currently is that no matter if it's a Touch or a Swipe, both if event is InputEventScreenDrag and elif event is InputEventScreenTouch: seems to be coming true, all the time.

asked Mar 19 in Engine by ishfwilf (19 points)

1 Answer

0 votes
Best answer

I solved it like this:

if event is InputEventScreenDrag:
    swiped = true

if event is InputEventScreenTouch:
        if event.is_pressed():
            print("pressed...")
        if not event.pressed:
            if swiped:
                calculate_swipe(event)
                get_tree().set_input_as_handled()
                return
            calculate_touch(event)
            #emit_signal("none")

swiped is set to false in calculate_swipe

answered Aug 14 by ishfwilf (19 points)
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.