I'm tring to tween a bunch of sprites (about a hundred) to appear on screen. I wan't them to appear one by one, with a small interval inbetween. This is easily done:

for sprite in sprites:
	tween.tween_callback(sprite.show)
	tween.tween_interval(0.1)

I also want to scale them as they appear, using something like this:

tween.tween_property(sprite, "scale:x", 1.0, 1).from(0.0)

But I haven't found a way to do this without it increasing the interval inbetween each sprite. The interval should stay at 0.1, but instead it takes much longer because it is waiting for the scaling tweener to finish. I tried various combinations using .parallel() and .chain() but the delay is always there.

I did fix it by using .set_delay() like this:

tween = create_tween().set_parallel()
var delay := 0.1
for i in sprites.size():
	tween.tween_callback(sprites[i].show).set_delay(i * delay)
	tween.tween_property(sprites[i], "scale:x", 1.0, 1).from(0.0).set_delay(i * delay)

But then I'm just manually setting each tweener's delay and not actually using any chaining.
So is it even possible to chain them like this?

  • xyz replied to this.
  • ainc Tweeners are put in a queue and are run sequentially. A tweener can either run in parallel with a previous one in the queue or can wait until that previous one finishes and then run.

    What you want to do has two overlapping sequences so a single tween can't do it. It needs to be either custom delays or two separate tweens, each handling one sequence.

    ainc changed the title to Are some tween chains impossible to do with a single tween? .

    ainc But then I'm just manually setting each tweener's delay and not actually using any chaining.

    What's wrong with that?

    • ainc replied to this.

      xyz Nothing, I guess I just expected it to be possible and wasted my time trying to get it to work

      • xyz replied to this.
        • Edited
        • Best Answerset by ainc

        ainc Tweeners are put in a queue and are run sequentially. A tweener can either run in parallel with a previous one in the queue or can wait until that previous one finishes and then run.

        What you want to do has two overlapping sequences so a single tween can't do it. It needs to be either custom delays or two separate tweens, each handling one sequence.

        @ainc what about something like this?

        func _ready() -> void:
        	var tween = get_tree().create_tween()
        	for sprite in sprites:
        		tween.tween_callback(sprite.show)
        		tween.tween_callback(tween_two.bind(sprite))
        		tween.tween_interval(0.1)
        
        func tween_two(sprite):
        	var tween2 = get_tree().create_tween()
        	tween2.tween_property(sprite, "scale:x", 1.0, 1).from(0.0)

        As @xyz said, this way requires separate tweens. Actually a new tween is generated per sprite, but it runs just fine.

        • ainc replied to this.