Fixed a path following problem in AISprite.action_wander

This commit is contained in:
2014-07-06 21:30:18 -07:00
parent 5aaa025537
commit 870c00d537
2 changed files with 16 additions and 26 deletions

View File

@@ -633,28 +633,8 @@
"x":0,
"y":0
},
{
"x":0,
"y":32
},
{
"x":64,
"y":96
},
{
"x":288,
"y":96
},
{
"x":352,
"y":32
},
{
"x":352,
"y":0
},
{
"x":0,
"y":0
}],
"properties":

View File

@@ -606,21 +606,31 @@ var AISprite = function(game, x, y, key, frame) {
return;
}
if ( isSet(this.sprite_route) == true ) {
if ( this.path.length > 0 && this.path_index >= this.path.length ) {
if ( this.path.length > 0 &&
this.path_index >= this.path.length &&
isSet(this.target) &&
this.x == this.target.x &&
this.y == this.target.y ) {
this.sprite_route_index += 1;
if ( this.sprite_route_index >= this.sprite_route.polyline.length )
this.sprite_route_index = 0;
this.path_purge();
}
if ( this.sprite_route_index >= this.sprite_route.polyline.length )
this.sprite_route_index = 0;
var dpoint = this.sprite_route.polyline[this.sprite_route_index];
if ( isSet(this.target) == false ) {
this.target = new Phaser.Sprite(null,
this.sprite_route.x + dpoint[0],
this.sprite_route.y + dpoint[1]);
} else {
if ( isSet(this.target.sprite_group) == true ) {
this.target = new Phaser.Sprite(null,
this.sprite_route.x + dpoint[0],
this.sprite_route.y + dpoint[1]);
} else {
this.target.x = this.sprite_route.x + dpoint[0];
this.target.y = this.sprite_route.y + dpoint[1];
}
}
this.chasetarget(this.target,
STATE_NONE,
STATE_MOVING,