Phaser update sprite texture
<p>I have a problem updating a sprite.</p>

<p>I created a function to change clothes. This should work like:</p>

<pre><code>// Something like this.
pet = pet_with_hat
</code></pre>

<p>There is code at <a href="https://github.com/futer/pandachii" rel="nofollow">https://github.com/futer/pandachii</a> in in js/main.js, line 387.</p>

<p>When I write this:</p>

<pre><code>this.pet = this.game.add.sprite(90,90, 'pet_black_hat')
</code></pre>

<p>There is an error:</p>

<pre>
 Uncaught TypeError: Cannot read property 'health' of undefined
 GameState.update @ main.js:194
 Phaser.StateManager.update @ phaser.js:16628
 Phaser.Game.update @ phaser.js:23092
 Phaser.RequestAnimationFrame.updateRAF @ phaser.js:41421
 _onLoop @ phaser.js:41407
</pre>

<p>How do I change the sprite image for this pet to another?</p>

<p>I will be grateful.</p>