toto88x Posted January 25, 2014 Report Share Posted January 25, 2014 Hello! 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 More sharing options...
rich Posted January 25, 2014 Report Share Posted January 25, 2014 To answer the second one - keep a reference to the tween somewhere, i.e.:var planeTween = game.add.tween(plane).to(...)And then call:planeTween.stop(); Link to comment Share on other sites More sharing options...
toto88x Posted January 25, 2014 Author Report Share Posted January 25, 2014 Thanks, that what I thought. So I guess there's no way for a given sprite to easily find the tween associated to it, something like sprite.tweens. Anyway, I'm still looking for help on how to use the yoyo() function. Thanks! :-) Link to comment Share on other sites More sharing options...
toto88x Posted January 28, 2014 Author Report Share Posted January 28, 2014 Anyone can help me with first question: how to make to yoyo function work? Thanks! Link to comment Share on other sites More sharing options...
Sands Posted September 23, 2014 Report Share Posted September 23, 2014 HelloI 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 More sharing options...
Recommended Posts