Jump to content

Tween understanding


Raiper34
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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