+1 vote

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

in Engine by (254 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()
by (254 points)

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

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.