Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | WeTech |
So I started with godot recently and went straight into making my first game. The problem is a simple code runs really slow and I have no idea how to change it. (found no working solution) . All the scenes are almost the same so far.
Tested device: Redmi note 4 and note 7
Scene: Node 2D - CanvasLayer (-TextureRect with image) and RichLabelText
The code:
extends Node2D
var swipe_start = null
var minimum_drag = 50
func _unhandled_input(event):
if event is InputEventScreenTouch:
if event.pressed:
extends Node2D
var swipe_start = null
var minimum_drag = 50
func _unhandled_input(event):
if event is InputEventScreenTouch:
if event.pressed:
swipe_start = event.get_position()
else:
_calculate_swipe(event.get_position())
func _calculate_swipe(swipe_end):
if swipe_start == null:
return
var swipe = swipe_end - swipe_start
if abs(swipe.x) > minimum_drag:
if swipe.x < -50:
get_tree().change_scene("res://Beg1.tscn")
The delay between the swipe and change of scene is often 1-3s which feels terrific.
Played with fps a bit too and it shows about 20 drop from 60 when swiped.