Skip to content

Commit

Permalink
keep track of tween to prevent slipping (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheubel authored Oct 28, 2023
1 parent a4e44f6 commit c89b03e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions addons/dialogic/Modules/Text/node_next_indicator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extends Control
if has_node('Texture'):
get_node('Texture').texture = texture

var tween: Tween

func _ready():
add_to_group('dialogic_next_indicator')
Expand All @@ -43,8 +44,12 @@ func _on_visibility_changed():


func play_animation(animation: int, time:float) -> void:
# clean up previous tween to prevent slipping
if tween:
tween.stop()

if animation == 0:
var tween:Tween = (create_tween() as Tween)
tween = (create_tween() as Tween)
var distance := 4
tween.set_parallel(false)
tween.set_trans(Tween.TRANS_SINE)
Expand All @@ -54,7 +59,7 @@ func play_animation(animation: int, time:float) -> void:
tween.tween_property(self, 'position', Vector2(0,distance), time*0.3).as_relative()
tween.tween_property(self, 'position', - Vector2(0,distance), time*0.3).as_relative()
if animation == 1:
var tween:Tween = (create_tween() as Tween)
tween = (create_tween() as Tween)
tween.set_parallel(false)
tween.set_trans(Tween.TRANS_SINE)
tween.set_ease(Tween.EASE_IN_OUT)
Expand Down

0 comments on commit c89b03e

Please sign in to comment.