Raiper34 Posted July 11, 2015 Share Posted July 11, 2015 Hi, I am trying to make gotoXY function using Tween, i do this:player.prototype.initMove = function(){ this.movement = this.game.add.tween(this); this.movement.onComplete.add(this.goComplete, this);};player.prototype.goTo = function(x, y){ if(this.walking == false) { this.xDest = x; this.yDest = y; this.walking = true; this.movement.to( { x: x, y: y }, 500 , "Linear", true); }};but always spite go previous paths too.... so my question is, shoudl i always create new tween and on complete destory it, or is possible to any clear path, because i want to go only on current xy, not previously.... Thanks. Link to comment Share on other sites More sharing options...
Raiper34 Posted July 11, 2015 Author Share Posted July 11, 2015 In short, i add one tween to game, and then i call .to method... Link to comment Share on other sites More sharing options...
substandardgaussian Posted July 11, 2015 Share Posted July 11, 2015 The .to and .from methods add tween data to the tween, they don't override it. You can do some trickery to remove previous data (set tween.timeline to an empty array before calling to or from), but it looks like tweens in Phaser are meant to be disposable. I don't think their behavior is guaranteed if you mess around with the internals. Raiper34 1 Link to comment Share on other sites More sharing options...
Recommended Posts