Hey Godot Forum!
I am making a simple mobile game and I am now on the point where I am implementing touch controls into my game.
I want it to go up when I tap the screen and to the side when I swipe left or right ( and down if I swipe down ).
However whenever I try to put in the tap control it will override the swipe controls everytime. I believe this is because that when I first touch the screen, it registers as a tap and doesn't care if I swipe the screen after that. If anyone has any solutions to fix this problem that would be much appreciated! Anyway, code is down below! ( tap code is commented out )
extends Node2D
func _input(event):
var is_drag = event is InputEventScreenDrag
var is_press = !is_drag and event.is_pressed()
var is_release = !is_drag and !event.is_pressed()
if is_drag:
if $TouchScreenClass.get_drag_direction(event.relative, 25) == Vector2.DOWN:
print("down")
$TouchScreenClass._on_self_released()
if $TouchScreenClass.get_drag_direction(event.relative, 25) == Vector2.UP:
print("up")
$TouchScreenClass._on_self_released()
if $TouchScreenClass.get_drag_direction(event.relative, 25) == Vector2.LEFT:
print("left")
$TouchScreenClass._on_self_released()
if $TouchScreenClass.get_drag_direction(event.relative, 25) == Vector2.RIGHT:
print("right")
$TouchScreenClass._on_self_released()
# if event is InputEventScreenTouch:
# if event.pressed:
# print("tap!")