From 870c00d537bf6312fdbb0b01d1df6b794bfcd6d3 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sun, 6 Jul 2014 21:30:18 -0700 Subject: [PATCH] Fixed a path following problem in AISprite.action_wander --- moonlight/gfx/map.json | 20 -------------------- moonlight/src/AISprite.js | 22 ++++++++++++++++------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/moonlight/gfx/map.json b/moonlight/gfx/map.json index 986309c..46ebad4 100644 --- a/moonlight/gfx/map.json +++ b/moonlight/gfx/map.json @@ -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": diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index 3d07823..988ecaa 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -606,20 +606,30 @@ 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 ) { + if ( isSet(this.target) == false ) { 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]; + 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,