Close #33 : Destroy all unused sprites when we're done with them
This commit is contained in:
@@ -75,6 +75,8 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
|
|
||||||
this.runGlintEffect = function() {
|
this.runGlintEffect = function() {
|
||||||
if ( this.sprite_has_treasure == true ) {
|
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.glint_effect = game.state.states.game.add.sprite(
|
||||||
this.x + 16,
|
this.x + 16,
|
||||||
this.y + 24,
|
this.y + 24,
|
||||||
@@ -143,6 +145,8 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
|
|
||||||
this.bubble_immediate = true;
|
this.bubble_immediate = true;
|
||||||
this.clearWordBubble();
|
this.clearWordBubble();
|
||||||
|
if ( isSet(this.awareness_effect) == true )
|
||||||
|
this.awareness_effect.destroy();
|
||||||
this.awareness_effect = game.state.states.game.add.sprite(
|
this.awareness_effect = game.state.states.game.add.sprite(
|
||||||
this.x + 16,
|
this.x + 16,
|
||||||
this.y - 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)];
|
text = mylines[game.rnd.integerInRange(0, mylines.length-1)];
|
||||||
style = {font: '14px Arial Bold', fill: '#ffffff'}
|
style = {font: '14px Arial Bold', fill: '#ffffff'}
|
||||||
this.text_size = stringSize(text, style['font']);
|
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 = game.add.sprite(this.x, this.y, 'wordbubble');
|
||||||
this.bubble_sprite.anchor.setTo(0.5, 1.0);
|
this.bubble_sprite.anchor.setTo(0.5, 1.0);
|
||||||
this.bubble_sprite.scale.x = Number((this.text_size[0] + 16) / bubbleimg.width);
|
this.bubble_sprite.scale.x = Number((this.text_size[0] + 16) / bubbleimg.width);
|
||||||
|
|||||||
@@ -309,6 +309,8 @@ GameState.prototype.update = function()
|
|||||||
if ( x.collide_with_player == false )
|
if ( x.collide_with_player == false )
|
||||||
return;
|
return;
|
||||||
if ( x.canSeeSprite(player, false) == true ) {
|
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.lastSawPlayerAt = new Phaser.Sprite(game, player.x, player.y, null);
|
||||||
if ( player.lightmeter >= x.sprite_can_see_lightmeter ) {
|
if ( player.lightmeter >= x.sprite_can_see_lightmeter ) {
|
||||||
x.setAwarenessEffect(STATE_ALERTED);
|
x.setAwarenessEffect(STATE_ALERTED);
|
||||||
@@ -375,7 +377,7 @@ GameState.prototype.update = function()
|
|||||||
rs.angle = 0;
|
rs.angle = 0;
|
||||||
tween = game.add.tween(rs);
|
tween = game.add.tween(rs);
|
||||||
tween.to({angle: 360}, 1000, null);
|
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.start();
|
||||||
tween = game.add.tween(rs.scale);
|
tween = game.add.tween(rs.scale);
|
||||||
tween.to({x: 1, y: 1}, 1000, null);
|
tween.to({x: 1, y: 1}, 1000, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user