Jazz Posted December 6, 2015 Share Posted December 6, 2015 Hello, im trying to tween the camera to the player position like this: this.cameraTween= game.add.tween(game.camera).to({y: (player.y- (game.camera.height /2)), x: (player.x- (game.camera.width /2))}, 500).start()this.cameraTweenBack.onComplete.add(function () {game.camera.follow(player);}, this); this is OK when the player is not moving.However when the player is moving the follow function will make it snap to the delta it moved during the tween.chaining tweens dint fix this problem for me Link to comment Share on other sites More sharing options...
Jazz Posted December 7, 2015 Author Share Posted December 7, 2015 Something like this works, but its to jittery this.onUpdate = function () { console.log("x: " + game.camera.x + "y: " + game.camera.y) game.tweens.remove(this.cameraTweenBack); if ((game.camera.y - (player.y - (game.camera.height / 2)) < 10) && (game.camera.x - (player.x - (game.camera.width / 2)) < 10)) { console.log("destination reached") game.camera.follow(player); } else { this.cameraTweenBack = game.add.tween(game.camera).to({ y: (player.y - (game.camera.height / 2)), x: (player.x - (game.camera.width / 2)) }, 50).start() this.cameraTweenBack.onUpdateCallback(this.onUpdate, this); } } Link to comment Share on other sites More sharing options...
Recommended Posts