0 votes

extends TouchScreenButton
var count = 0
var dragging = false
var clickradius = 32 # Size of the sprite.
var swipe
var minimumdrag = 100
func _input(event):
if event is InputEventScreenTouch and event.index == 0:
if not dragging and event.pressed:
dragging = true
start = event.getposition()
# Stop dragging if the button is released.
if dragging and not event.pressed:
dragging = false

func calculateswipe(swipeend):
if swipe
start == null:
var swipe = swipeend - swipestart
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

enter image description here

Godot version 3.3.4
in Engine by (30 points)


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?

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

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

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

Please log in or register to answer this question.

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.