Jump to content

onComplete for chained tweens


mcuz
 Share

Recommended Posts

I have a sprite with chained tweens and am wanting to destroy it when the chained tweens have completed.  Here is my code.  

 

tween = this.game.add.tween(enemy).delay(this.count * 110)
.to({ x: '+200' }, 800, Phaser.Easing.Linear.None)
.to({ x: '+400'}, 800, Phaser.Easing.Linear.None)
.to({ x: '+200'}, 800, Phaser.Easing.Linear.None)
.to({ x: '+200'}, 800, Phaser.Easing.Linear.None)
.start();
 
tween.onComplete.add(this.onComplete, enemy);
 
the onComplete function kills the enemy sprite.  However this fires after the first movement tween has
finished.  What I want is for the event to fire after the entire chain has completed - any ideas? much obliged
 
mcuz
 
Link to comment
Share on other sites

I also found myself asking this question for other tween callbacks . Not enough I also started my issue on phaser's github repos about this topic months ago. See here https://github.com/photonstorm/phaser/issues/348. This was during a more unstable time of phaser but this particular issue is still not solved- because it's an edge case and not really a problem.

 

Just keep in mind that you can always use TweenMax/TimelineMax or other tweening engines for more complex tweens. You're not stuck with the phaser tweens. They are meant as a lightweight tween engine but sometimes you're better with an external solution. It's not forbidden ;)

 

Anyway I don't want you to use TimelineMax because the callback is not working. It's working, Pedro already pointed you to the right answer!

Regards George

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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