Jump to content

Refresh chainedTween


Recommended Posts

I have this chainedTween working fine:


followPlayer: function() {


            //var path is recalculated ...


            var chainedTween = game.add.tween(this.enemy);


            for (var i = 1; i < path.length; i++) {


                    x: path[0] * this.tileSize,

                    y: path[1] * this.tileSize

                }, 400 + Math.random() * 200);






Basically its an enemy following the player. Now I need to "refresh" the tween everytime the player moves. Since the player moves using keyboard keys, the keyboard key isDown event, besides moving the player, also calls the "followPlayer" function. So I added "game.tweens.removeFrom(this.enemy, true);" in order to refresh the tween, but the result was that the enemy don't move while the keyboard key is down, starting to move only when its released.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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