diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index 6ff9c44..34648b6 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -75,6 +75,8 @@ var AISprite = function(game, x, y, key, frame) { this.runGlintEffect = function() { if ( this.sprite_has_treasure == true ) { + if ( isSet(this.glint_effect) == true ) + this.glint_effect.destroy(); this.glint_effect = game.state.states.game.add.sprite( this.x + 16, this.y + 24, @@ -143,6 +145,8 @@ var AISprite = function(game, x, y, key, frame) { this.bubble_immediate = true; this.clearWordBubble(); + if ( isSet(this.awareness_effect) == true ) + this.awareness_effect.destroy(); this.awareness_effect = game.state.states.game.add.sprite( this.x + 16, this.y - 16, @@ -206,6 +210,8 @@ var AISprite = function(game, x, y, key, frame) { text = mylines[game.rnd.integerInRange(0, mylines.length-1)]; style = {font: '14px Arial Bold', fill: '#ffffff'} this.text_size = stringSize(text, style['font']); + if ( isSet(this.bubble_sprite) == true ) + this.bubble_sprite.destroy(); this.bubble_sprite = game.add.sprite(this.x, this.y, 'wordbubble'); this.bubble_sprite.anchor.setTo(0.5, 1.0); this.bubble_sprite.scale.x = Number((this.text_size[0] + 16) / bubbleimg.width); diff --git a/moonlight/src/GameStates.js b/moonlight/src/GameStates.js index 6c9d5ac..f5aea93 100644 --- a/moonlight/src/GameStates.js +++ b/moonlight/src/GameStates.js @@ -309,6 +309,8 @@ 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); if ( player.lightmeter >= x.sprite_can_see_lightmeter ) { x.setAwarenessEffect(STATE_ALERTED); @@ -375,7 +377,7 @@ GameState.prototype.update = function() rs.angle = 0; tween = game.add.tween(rs); tween.to({angle: 360}, 1000, null); - tween.onComplete.add(function(){this.angle=0;}, this); + tween.onComplete.add(function(){this.angle=0;}, rs); tween.start(); tween = game.add.tween(rs.scale); tween.to({x: 1, y: 1}, 1000, null);