Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | psear |
I have UI elements, and I want to fade them in sequence, and with some modifiable delay by changing their CanvasItem modulate.a property.
I have made a tween node, “TweenMenu”, and given it
var node
func animate_fade(nodetoanimate, delay):
var node = nodetoanimate
interpolate_method(self, "fade", 0, 1, 1, EASETYPE, EASE, delay)
start()
func fade(x):
node.modulate.a = x
This means in the root node’s script I can have a very straightforward thing like this:
func _ready():
$TweenMenu.animate_fade($UIElementOne, 0)
$TweenMenu.animate_fade($UIElementTwo, 1)
$TweenMenu.animate_fade($UIElementThree, 2)
The problem is, this will only work on the last UI element I try to animate (Element three in the above example), because after it sets the interpolate method and starts it on the first UI element, it immediately changes to the next element.
I know I could do something with yield(), but I don’t want to wait for the tween to finish, because I would like the next UI element to start animating before the first one is done.
I hope I’ve explained well enough, what’s the best way to achieve what I want to achieve?