Godot Version
4.2.2
Hello everyone,
I am strugeling with understanding why my tween is not being executed when I send out my custom signal.
I have a “Game_Level” scene which is the parent of “Player”. In player I have this code:
extends Node2D
...
func swipe_detection():
if Input.is_action_just_pressed("press"):
print(swipeActive)
if !swipeActive:
swipeActive = true
startPosSwipe = get_global_mouse_position()
print("Start Position: ", startPosSwipe)
if Input.is_action_just_released("press") and swipeActive:
endPosSwipe = get_global_mouse_position()
print("End Position: ", endPosSwipe)
# calculate the drag distance in x and y
var deltaX = startPosSwipe.x - endPosSwipe.x
var deltaY = startPosSwipe.y - endPosSwipe.y
#print("deltaX: ", deltaX, " start Position: ", startPosSwipe.x, " End Position: ", endPosSwipe.x)
print("deltaY: ", deltaY, " start Position: ", startPosSwipe.y, " End Position: ", endPosSwipe.y)
if deltaX >= SWIPETHRESHOLDLeft and swipeActive:
print("Swipe left detected!")
swipeActive = false
left_swipe.emit()
.....
In the code above I emit the left_swipe signal to “Game_Level” every time i swipe left. This works to the point, that I can print in “Game_Level” every time i swipe left. Which shows me, that my signal is being emitted correctly.
The problem is though, that the tween is not being executed in the following “Game_Level” code:
extends Node2D
@onready var tween_left = get_tree().create_tween()
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_player_left_swipe():
print("Swipe signal detected")
tween_left.tween_property($Player, "position", Vector2(260, $Player.player_begin_pos_y), 1)
Could someone please explain why the tween is not being executed?
Also when I call the function _on_player_left_swipe() in func _process(delta) it is being executed right away. Even before I swipe and thus emit the signal. This makes not much sense to me.
Beste regards,
James