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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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