From ee2d30fd7e47ef03c3a39af1623cebef73a42c03 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 12 Jul 2014 08:29:41 -0700 Subject: [PATCH] Fix undefined error when reporting you to a guard --- moonlight/src/AISprite.js | 7 +++++++ moonlight/src/GameStates.js | 8 ++++---- moonlight/src/Settings.js | 4 ---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index f4258d3..fb7785d 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -737,6 +737,13 @@ var AISprite = function(game, x, y, key, frame) { } } + this.sawPlayer = function(game, player) + { + if ( isSet(this.lastSawPlayerAt) == true ) + this.lastSawPlayerAt.destroy(); + this.lastSawPlayerAt = new Phaser.Sprite(game, player.x, player.y, null); + } + this.update = function() { if ( this.ready_to_update == false ) diff --git a/moonlight/src/GameStates.js b/moonlight/src/GameStates.js index 1d8fb91..583fc8c 100644 --- a/moonlight/src/GameStates.js +++ b/moonlight/src/GameStates.js @@ -322,9 +322,7 @@ GameState.prototype.update = function() if ( x.collide_with_player == false ) return; if ( x.canSeeSprite(player, false) == true ) { - if ( isSet(x.lastSawPlayerAt) == true ) - x.lastSawPlayerAt.destroy(); - x.lastSawPlayerAt = new Phaser.Sprite(game, player.x, player.y, null); + x.sawPlayer(game, player); if ( player.lightmeter >= x.sprite_can_see_lightmeter ) { x.setAwarenessEffect(STATE_ALERTED); } else { @@ -340,8 +338,10 @@ GameState.prototype.update = function() x.setAwarenessEffect(STATE_UNAWARE); } } - if ( this.physics.arcade.overlap(x, player) == true ) + if ( this.physics.arcade.overlap(x, player) == true ) { + x.sawPlayer(game, player); x.setAwarenessEffect(STATE_ALERTED); + } if ( hasState(player, STATE_STEALING) == true && x.sprite_has_treasure == true ) { var prevpos = player.body.position; diff --git a/moonlight/src/Settings.js b/moonlight/src/Settings.js index 203d569..67c4905 100644 --- a/moonlight/src/Settings.js +++ b/moonlight/src/Settings.js @@ -147,10 +147,6 @@ var moonlightSettings = { } ], 'images': [ - { - 'name': 'lightbox', - 'path': 'gfx/ui/lightbox.png' - }, { 'name': 'hud', 'path': 'gfx/ui/hud.png'