Jump to content

Tween chaining ignores first tween


frokenstein
 Share

Recommended Posts

I am trying to chain tweens then run an onComplete once the final tween runs. Unfortunately Phaser ignores the fist tween. Any ideas why?

var tween = this.add.tween(this.alien).to({x: 500, y: 500}, 3000, Phaser.Easing.Linear.None).to({x: 0, y: 0}, 3000, Phaser.Easing.Linear.None).start();tween._lastChild.onComplete.add(function(){this.alien.isAttacking = true;}, this);

Once the tween is triggered the sprite goes to x: 0, y: 0 and completely ignores the first directive to go to x: 500, y: 500. I am using Phaser 2.2.0 RC7 and I'm wondering if there is a bug here.

Link to comment
Share on other sites

Use Tween.chain to chain tweens so in your case:

var tweenUp = this.add.tween(this.alien).to({x: 500, y: 500}, 3000, Phaser.Easing.Linear.None);var tweenZero = this.add.tween(this.alien).to({x: 0, y: 0}, 3000, Phaser.Easing.Linear.None);tweenUp.chain(tweenZero)tweenZero.onComplete.add(function(){ this.alien.isAttacking = true;}, this);tweenUp.start();
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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