Jump to content

phaser 3 complete current tween in timeline


dontHaveName
 Share

Recommended Posts

Hello,

is there any way to complete current tween in the timeline and then remove following tweens? I'm inserting tweens like this:

tweens.push({
   targets: this.sprite,
   x: { value: 50, duration: 1000 },
   y: { value: 50, duration: 1000 }
});
this.tweens.timeline({ tweens });

Then after some event I need to finish current tween and clear all following (if any). This seems to stop tweens:

this.tweens.killAll();

but I can't find anything to finish current tween at first.

 

Thanks

 

Link to comment
Share on other sites

Thinking out loud here.

You can add an onComplete callback to a tween. Ideally, you would reach your event and use it to add a callback to the currently running tween in the timeline. The callback would then stop the timeline or tweens in the timeline or just killAll().

I don't know how to detect the currently running tween in a timeline. Didn't go hunting myself, but you can see how the timeline works here: https://github.com/photonstorm/phaser/blob/master/src/tweens/Timeline.js

You could have your event attach your onComplete callback to all of the the tweens in the timeline.  Hacky but might work OK.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...