mcuz Posted April 21, 2014 Share Posted April 21, 2014 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 hasfinished. 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 More sharing options...
Pedro Alpera Posted April 22, 2014 Share Posted April 22, 2014 Try this:tween._lastChild.onComplete.add(onComplete, this);More info: http://www.html5gamedevs.com/topic/5187-tween-isrunning-only-on-first-step-of-sequence/?hl=_lastchild#entry31675 Link to comment Share on other sites More sharing options...
george Posted April 22, 2014 Share Posted April 22, 2014 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 More sharing options...
mcuz Posted April 24, 2014 Author Share Posted April 24, 2014 Thanks for that it worked out great Link to comment Share on other sites More sharing options...
Recommended Posts