From 76943f06e3fc32c29d1d1b7d43a4edc0745120d1 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Wed, 18 Jun 2014 09:04:37 -0700 Subject: [PATCH] Stop chasing me if you can't see me at the end of your path --- moonlight/js/moonlight-skulk.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index 75bda38..038b88a 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -995,6 +995,8 @@ var AISprite = function(game, x, y, key, frame) { } else if ( hasState(this, STATE_FACE_RIGHT) ) { setMovingState(this, STATE_FACE_DOWN); } + this.rotation_timer.stop(); + this.rotation_timer = null; } this.action_chaseplayer = function() @@ -1011,12 +1013,12 @@ var AISprite = function(game, x, y, key, frame) { this.path_set(player, true); this.path_tween_start(); } else { - 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); - timerev = this.rotation_timer.add(1000, this.turnFaceRight, this); - this.rotation_timer.start() + if ( this.rotation_timer == null ) { + console.log("I can't see the player - turning so I can"); + this.rotation_timer = game.time.create(false); + timerev = this.rotation_timer.add(1000, this.turnFaceRight, this); + this.rotation_timer.start() + } } } else { if ( this.path_set(player, this.blocked(true)) == true ) {