How do I reset a tween?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By imekon
:warning: Old Version Published before Godot 3 was released.

Once I’ve used a tween, how do I use it again?

I’ve got two tweens set up to fade out a label and fade in a label. However, once I’ve used them, they don’t work again. I tried calling reset, but that had no effect.

func _ready():
    tweenOut.interpolate_property(label, "visibility/opacity", 1.0, 0.0, 3.0, Tween.TRANS_QUAD, Tween.EASE_OUT)
    tweenIn.interpolate_property(label, "visibility/opacity", 0.0, 1.0, 3.0, Tween.TRANS_QUAD, Tween.EASE_IN)

func _onFadeOut():
    tweenOut.reset(label, "visibility/opacity")
    tweenOut.start()

func _onFadeIn():
    tweenIn.reset(label, "visibility/opacity")
    tweenIn.start()

I’ve put the code here: https://github.com/imekon/godot-unofficial-demo-projects/tree/master/TweeningIt

:bust_in_silhouette: Reply From: imekon

The answer is to move the interpolate_property calls:

func _onFadeOut():
    tweenOut.interpolate_property(label, "visibility/opacity", 1.0, 0.0, 3.0, Tween.TRANS_QUAD, Tween.EASE_OUT)
    tweenOut.start()

func _onFadeIn():
    tweenIn.interpolate_property(label, "visibility/opacity", 0.0, 1.0, 3.0, Tween.TRANS_QUAD, Tween.EASE_IN)
    tweenIn.start()

i don’t get why they do this , since tween is a node , all its param should stay the same after reseting and should be able to be call start() anywhere, shouldnt that be easier

kietjay123 | 2020-08-17 03:28