Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Two small questions about tweens.


Recommended Posts



I have two small questions about tweens in Phaser.


1) How can I use correctly the yoyo() function for a tween? For example I tried this, and it doesn't work. What I am missing?

game.add.tween(car)  .to({ x: 500 }, 1000, Phaser.Easing.Linear.None)  .yoyo(true).loop().start();

2) I have a group of sprites (planes). When I create a new plane, I add a tween to it. How can I stop the tween when the sprite dies (because it's outOfBoud)? Edit: this one was answered below, thanks! :-)

var plane = this.planes.getFirstExists(false);plane.outOfBoundsKill = true;game.add.tween(plane).to({ x: 500, y: 500 }, 1000, Phaser.Easing.Linear.None).start();

Thanks for your help! :-)

Link to comment
Share on other sites

  • 7 months later...


I had a similar issue like question number 1. I needed a looping yoyo tween, but using "loop" just didn't work.

For anyone else looking at this, try using repeat:

game.add.tween(car).to({ x: 500 }, 1000, Phaser.Easing.Linear.None).yoyo(true).repeat(Number.MAX_VALUE).start();
Link to comment
Share on other sites


  • Recently Browsing   0 members

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