Jump to content

Delay after tween's end


ZoomBox
 Share

Recommended Posts

Hey,

 

I know it's possible to have a delay before a tween start but I would like to know if it's possible to have a delay after the tween ends.

The goal is to wait before onComplete(function, args); is fired.

 

Thank you :-)

Link to comment
Share on other sites

The onComplete event always fires at the end of the tween, but it's easy to create a delay within that callback:

var tween = game.add.tween(sprite).to({x: 200}, 2000, Phaser.Easing.Quadratic.InOut);tween.onComplete.add(function() {  game.time.events.add(1000, function() {    // anything here will happen 1 second after the tween has ended  }, this);}, this);tween.start();

Or of course chain it all together:

game.add.tween(sprite).to({x: 200}, 2000, Phaser.Easing.Quadratic.InOut, true).onComplete.add(function() {  game.time.events.add(1000, function() {    // anything here will happen 1 second after the tween has ended  }, this);}, this);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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