Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tween chain never completes #1871

Closed
IBwWG opened this issue Jun 18, 2016 · 5 comments
Closed

Tween chain never completes #1871

IBwWG opened this issue Jun 18, 2016 · 5 comments
Milestone

Comments

@IBwWG
Copy link
Contributor

IBwWG commented Jun 18, 2016

  • Flixel version: 4.0.0
  • OpenFL version: 3.6.1
  • Lime version: 2.9.1
  • Affected targets: windows/debug

Code snippet reproducing the issue:

package;
import flixel.FlxState;
import flixel.tweens.FlxTween;

class PlayState extends FlxState
{
    override public function create():Void 
    {
        var fakeThing = { a: 0, b: 0 };

        FlxTween.tween(fakeThing, { a: 1 }).then(FlxTween.num(0,1).then(FlxTween.num(0,1))).onComplete = function (dummy:FlxTween)
        {
            trace("done A");
        };
        FlxTween.tween(fakeThing, { b: 1 }).then(FlxTween.num(0,1).then(FlxTween.num(0,1,1, {onComplete: function (dummy:FlxTween)
        {
            trace("done B");
        }})));
    }
}

Observed behavior: done B not traced
Expected behavior: done B should be traced

I realize the two things are not semantically equivalent, but they should both call their completion functions, shouldn't they? The first one should tween, trace, num, num (tracing after 1 second); the second should tween, num, num, trace (tracing after 3 seconds). But the second one never traces. (And of course, this is the one you'd expect from a general concept of chaining.)

Take out a num tween, or take away the tween tween, and they both trace as expected.

@Gama11 Gama11 added the Bug label Jun 18, 2016
@Gama11 Gama11 added this to the 4.1.0 milestone Jun 18, 2016
@IBwWG
Copy link
Contributor Author

IBwWG commented Jun 18, 2016

One workaround:

        FlxTween.tween(fakeThing, { c: 1 }, 1, { onComplete:function (dummy:FlxTween) {
            FlxTween.num(0, 1).then(FlxTween.num(0, 1, 1, { onComplete: function (dummy:FlxTween) {
                trace("done C");
            }}));
        }});

This traces properly, and after 3 seconds.

@Gama11 Gama11 closed this as completed in e469a4a Jun 18, 2016
@Gama11
Copy link
Member

Gama11 commented Jun 18, 2016

Chaining simply didn't account for nested chains... I hope it works as expected now.

Writing the unit tests for this one was fun. :D

@IBwWG
Copy link
Contributor Author

IBwWG commented Jun 20, 2016

Huh...I'll have to try it out, but that's interesting, because in the above example, it does work with nested chains, just not 3 levels, for some reason...2 worked fine.

But I also wonder, do I have the chaining syntax incorrect? Is it supposed to be .then(tween).then() instead of .then(tween.then()) in normal usage? For some reason I thought I had either tried that or traced it and thought it needed to be nested to work. I thought because .then() returned the original tween, so originalTween.then(tweenA).then(tweenB) would start A and B simultaneously after original finished.

@Gama11
Copy link
Member

Gama11 commented Jun 20, 2016

The .then(tween).then() seems more common to me.

originalTween.then(tweenA).then(tweenB) shouldn't start A and B at the same time, it should run originalTween, A and then B.

@IBwWG
Copy link
Contributor Author

IBwWG commented Jun 20, 2016

You're right! I could've sworn I tried that. Maybe I got confused because I was trying to finish with .onComplete = ... at the same time, which isn't possible with chained tweens because it applies to the first tween rather than the last. Thanks for the sanity check!

Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this issue Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants