why touch adding extra count when i move touch in backward direction ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By abhinavsingh

extends TouchScreenButton
var count = 0
var dragging = false
var click_radius = 32 # Size of the sprite.
var swipe_start
var minimum_drag = 100
func _input(event):
if event is InputEventScreenTouch and event.index == 0:
if not dragging and event.pressed:
dragging = true
swipe_start = event.get_position()
# Stop dragging if the button is released.
if dragging and not event.pressed:
dragging = false

func _calculate_swipe(swipe_end):
if swipe_start == null:
var swipe = swipe_end - swipe_start
if abs(swipe.x) > minimum_drag:
if swipe.x > 0:

func _right():
count += 1
func _left():
count -= 1

i need help on count not working properly


ramazan | 2022-01-06 08:43

Please help us by properly formatting your code. Also, do you know for certain if there’s any point in this program where swipe.x is negative?

Ertain | 2022-01-06 09:49

thanks for your help but
now i have changed the code and now it is working properly

abhinavsingh | 2022-01-06 10:11

Could you tell us what you changed so that your answer could help other people?

Ertain | 2022-01-06 18:42

ok answer is
touchscreen adding or subtraction value from array have a glitch in code not working correctly like it count wrong one extra number every time when we do swipe
so we have added two touch signals signal pressed and signal released to touchcontrol
and control them from new function

abhinavsingh | 2022-01-07 06:31