0 votes

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

asked Nov 26, 2017 in Engine by imekon (229 points)

1 Answer

+2 votes

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()
answered Nov 26, 2017 by imekon (229 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.