Aymen

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. This is my async.forEachSeries function: async.forEachSeries(parsed.moves,function(move, callback) { that.moveObj(move, callback) }, function() { console.log('done running the entire code') }); Move object is starting the tween and calling the callback onComplete of the tween. moveObject(x, y, obj,callbackToAsync, offsetX = 0, offsetY = 0) { let coordinates = this.convert(obj.i + offsetX,obj.j + offsetY) let tween = this.game.add.tween(obj, this.game, this.game.tweens).to({ x: coordinates.x, y: coordinates.y }, 2000) tween.onComplete.add(callbackToAsync,this) tween.start() } So from my understanding, each move should be called and after the tween for that move is complete it should call the callback and proceed to the next iteration with the next move in the array. What ends up happening is that the first move is executed and then it goes to the function that should be called when all iterations are done without completing all the iterations. I've made sure that the moves array has more than one object. So this has something to do with the tween, since when I simply call the callback in moveOb it processes the moves sequentially.