GreG28 Posted December 15, 2014 Share Posted December 15, 2014 Hello everyone, I'm actually working on a Phaser Game.I'm already done a pathfinding for getting the path my soldier should take.Now I would like to make tweens for it and create a chained tween with each tile of the path. Every infos I found don't speak about creating a tween object.Like it we could add new steps to it and after assign it to a sprite for example and play it. Sorry for my english... (FrenchStyle ^^) github : GreG28 Link to comment Share on other sites More sharing options...
pxam Posted December 16, 2014 Share Posted December 16, 2014 hi,chaining tweens is simple//some coordinatesvar steps = [ {x: 100, y: 100}, {x: 100, y: 150}, {x: 100, y: 200}, {x: 150, y: 200}, {x: 200, y: 200}];//createthis.chainedTween = this.add.tween(this.mySprite);//attachfor (var i = 0; i < steps.length; i++) { this.chainedTween.to({ x: steps[i].x, y: steps[i].y }, 500, "Quad.easeOut");}this.chainedTween.start();or you can use the chain methodvar tweenA = this.add.tween(this.mySprite).to({x: 100, y: 250}, 1000);var tweenB = this.add.tween(this.mySprite).to({x: 250, y: 150}, 1000);var tweenC = this.add.tween(this.mySprite).to({x: 350, y: 200}, 1000);tweenA.chain(tweenB, tweenC);tweenA.start(); Link to comment Share on other sites More sharing options...
Recommended Posts