Fix undefined error when reporting you to a guard

This commit is contained in:
2014-07-12 08:29:41 -07:00
parent 3504265879
commit ee2d30fd7e
3 changed files with 11 additions and 8 deletions

View File

@@ -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 )

View File

@@ -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;

View File

@@ -147,10 +147,6 @@ var moonlightSettings = {
}
],
'images': [
{
'name': 'lightbox',
'path': 'gfx/ui/lightbox.png'
},
{
'name': 'hud',
'path': 'gfx/ui/hud.png'