PathFollower using a new number tween internally.

This commit is contained in:
Richard Davey 2017-09-27 02:32:39 +01:00
parent 76288f0b3a
commit 84b74a13b6

View file

@ -19,10 +19,6 @@ var PathFollower = new Class({
this.pathVector = new Vector2();
this.pathTween;
this.pathData = {
t: 0
};
},
start: function (config)
@ -34,28 +30,17 @@ var PathFollower = new Class({
config = { duration: config };
}
// Add the targets and property into the mix
config.targets = this.pathData;
config.t = 1;
// Override in case they've been specified in the config
config.from = 0;
config.to = 1;
this.pathTween = this.scene.sys.tweens.add(config);
this.pathTween = this.scene.sys.tweens.addCounter(config);
// The starting point of the path, relative to this follower
this.path.getStartPoint(this.pathOffset);
// this.path.getStartPoint(this.pathOffset);
var start = this.path.getStartPoint();
// console.log('getStartPoint', this.pathOffset.x, this.pathOffset.y);
console.log('getStartPoint2', this.x, this.y);
var diffX = this.x - start.x;
var diffY = this.y - start.y;
console.log('diffX', diffX, 'diffY', diffY);
this.pathOffset.set(diffX, diffY);
this.pathOffset.x = this.x - this.pathOffset.x;
this.pathOffset.y = this.y - this.pathOffset.y;
},
/*
@ -87,7 +72,7 @@ var PathFollower = new Class({
if (this.pathTween && this.pathTween.isPlaying())
{
this.path.getPoint(this.pathData.t, this.pathVector);
this.path.getPoint(this.pathTween.getValue(), this.pathVector);
this.pathVector.add(this.pathOffset);