Stop chasing me if you can't see me at the end of your path

This commit is contained in:
2014-06-18 09:04:37 -07:00
parent 2f6c4acd57
commit 76943f06e3

View File

@@ -995,6 +995,8 @@ var AISprite = function(game, x, y, key, frame) {
} else if ( hasState(this, STATE_FACE_RIGHT) ) { } else if ( hasState(this, STATE_FACE_RIGHT) ) {
setMovingState(this, STATE_FACE_DOWN); setMovingState(this, STATE_FACE_DOWN);
} }
this.rotation_timer.stop();
this.rotation_timer = null;
} }
this.action_chaseplayer = function() this.action_chaseplayer = function()
@@ -1011,13 +1013,13 @@ var AISprite = function(game, x, y, key, frame) {
this.path_set(player, true); this.path_set(player, true);
this.path_tween_start(); this.path_tween_start();
} else { } else {
if ( this.rotation_timer == null ) {
console.log("I can't see the player - turning so I can"); console.log("I can't see the player - turning so I can");
if ( this.rotation_timer !== null )
this.rotation_timer.stop();
this.rotation_timer = game.time.create(false); this.rotation_timer = game.time.create(false);
timerev = this.rotation_timer.add(1000, this.turnFaceRight, this); timerev = this.rotation_timer.add(1000, this.turnFaceRight, this);
this.rotation_timer.start() this.rotation_timer.start()
} }
}
} else { } else {
if ( this.path_set(player, this.blocked(true)) == true ) { if ( this.path_set(player, this.blocked(true)) == true ) {
console.log("I just got a new path"); console.log("I just got a new path");