ok, I have a scene with area2D that rotates 45 degrees when clicked.
I have it nicely rotating with the elastic tween, BUT, if you click several times quickly, the rotation snaps...
First question, how do I stop it from doing this, im suspecting a yield command somewhere as the input will keep calling the rotation on each click, maybe!, but I dont think Im using it right, I keep getting an error,
" First argument of yield() not of type object. "
Second question, in a separate scene, I want several of these rotating on click Area2Ds, again, they seem to work ok, but they do seem to snap to a non 45 degree rotation, rather than smoothly rotating 45 degs. It seems to happen more often when 2 or more of them are lined up with each others rotation. I REALLY dont want this snapping, how do I stop this also!!
This is for my attempt at the current GoGodot jam!
extends Node2D
signal i_did_a_rotate
onready var tween = get_node("Tween")
onready var can_rotate = false
onready var current_rotation = $Area2D.rotation_degrees
onready var new_rotation = $Area2D.rotation_degrees
func _unhandled_input(_event):
if Input.is_mouse_button_pressed(1) and can_rotate == true:
_rotate_the_thing()
if Input.is_mouse_button_pressed(2) and can_rotate == true:
yield(_rotate_the_thing_backwards(), "i_did_a_rotate") # <<< computer says no...
func _rotate_the_thing():
print("should be doing something")
new_rotation += 45
tween.interpolate_property($Area2D, "rotation_degrees", current_rotation, new_rotation, 0.75, Tween.TRANS_ELASTIC, Tween.EASE_IN_OUT)
tween.start()
current_rotation = new_rotation
print("should have done something")
emit_signal("i_did_a_rotate")
func _rotate_the_thing_backwards():
new_rotation -= 45
tween.interpolate_property($Area2D, "rotation_degrees", current_rotation, new_rotation, 0.75, Tween.TRANS_ELASTIC, Tween.EASE_IN_OUT)
tween.start()
current_rotation = new_rotation
emit_signal("i_did_a_rotate")
func _on_Area2D_mouse_entered():
can_rotate = true
func _on_Area2D_mouse_exited():
can_rotate = false