From 73116da63284704a2f5d279129acd81af82877af Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 17 Feb 2020 13:29:37 +0100 Subject: [PATCH] check for slide length --- game/src/Taquin.gd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/game/src/Taquin.gd b/game/src/Taquin.gd index b98bd9b..5496c52 100644 --- a/game/src/Taquin.gd +++ b/game/src/Taquin.gd @@ -23,6 +23,7 @@ var current_animation_path := "AnimationPlayer/MockPiece:position" var swipe := Vector2(0, 0) var is_sliding := false +var minimum_slide_length := 5.0 var current_sliding_piece: Piece = null var missing_piece: Piece = null @@ -118,7 +119,10 @@ func _input(event): # if event is InputEventScreenDrag: swipe = event.relative - if not is_sliding: + # We check that the slide to have a minimum length + # before detecting the direction to avoid jittering. + if swipe.length() > minimum_slide_length and not is_sliding: + print("sliding started") is_sliding = true current_touch_slide = Vector2.ZERO var angle = swipe.angle()