Diffstat (limited to 'SwipeHandler.gd')
| -rw-r--r-- | SwipeHandler.gd | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/SwipeHandler.gd b/SwipeHandler.gd index d6a5cd3..362ebf7 100644 --- a/SwipeHandler.gd +++ b/SwipeHandler.gd @@ -9,29 +9,6 @@ var swiping := false export var swipe_limit : float export var touch_y_limit : int -var swipe_start - -var quick_trigger = 150 - -func _ready(): - set_process(not OS.has_touchscreen_ui_hint()) - set_process_input(OS.has_touchscreen_ui_hint()) - -func _input(event): - if event is InputEventScreenTouch: - if event.pressed: - swipe_start = event.position - elif swipe_start != null: - var distance = swipe_start.distance_to(event.position) - if distance > swipe_limit: - calculate_swipe(swipe_start.direction_to(event.position)) - if event is InputEventScreenDrag: - if abs(event.speed.x) > quick_trigger || abs(event.speed.y) > quick_trigger: - if swipe_start != null: - calculate_swipe((swipe_start.direction_to(event.position))) - print(swipe_start.direction_to(event.position)) - swipe_start = null - func _process(_delta): if Input.is_action_just_pressed("touch"): if ( get_global_mouse_position().y > touch_y_limit): @@ -59,12 +36,3 @@ func calculate_direction(): emit_signal("swiped", Vector2.LEFT) -func calculate_swipe(dist): - if dist.x > .5: - emit_signal("swiped", Vector2.RIGHT) - elif dist.x < -.5: - emit_signal("swiped", Vector2.LEFT) - elif dist.y > .5: - emit_signal("swiped", Vector2.DOWN) - elif dist.y < -.5: - emit_signal("swiped", Vector2.UP)
\ No newline at end of file |