title: Destroying sprites in Phaser
body: <p>I'm having trouble destroying Sprites in Phaser.</p>
  
  <p>I have a JavaScript object, let's call it Block. Block has a sprite property, that gets set like so:</p>
  
  <pre><code>this.sprite = this.game.add.sprite(this.x, this.y, 'blocks', this.color);
  </code></pre>
  
  <p>At a certain point in my code, Block is referenced by two different arrays:</p>
  
  <pre><code>square[0] = Block;
  destroy[0] = Block;
  </code></pre>
  
  <p>On a certain Update() cycle, I need to destroy the sprite, so I'm using the following code:</p>
  
  <pre><code>square[0].sprite.destroy(true); //Destroy the sprite.
  square[0] = null; //Remove the reference.
  </code></pre>
  
  <p>On the next Update() cycle, when I look at destroy[0], I would expect to see:</p>
  
  <pre><code>destroy[0].sprite: null
  </code></pre>
  
  <p>However what I'm seeing is:</p>
  
  <pre><code>destroy[0].sprite: b.Sprite
  </code></pre>
  
  <p>With the properties just defaulted and set to false. My worry is, if I were to now set destroy[0] to null, what will happen to that sprite object? </p>
  
  <p>Will it just float around or will it get cleaned up automatically?
  Should I be destroying the Block object first in some way?
  Also, if destroy() is not nulling the reference, how is it different from kill()?</p>
  
  <p>Any thoughts on the matter will be greatly appreciated.</p>