mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 05:58:30 +00:00
PathFollower using a new number tween internally.
This commit is contained in:
parent
76288f0b3a
commit
84b74a13b6
1 changed files with 8 additions and 23 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue