Jump to content

Changing sprite asset, old image stuck in cache


Tristan_AG
 Share

Recommended Posts

Hello,

 

I'm new to Phaser and have just run through the first tutorial (the star collecting game) on Phaser.io

 

Upon completing the tutorial I've decided to experiment a bit and update the sprites with some of my own creations, just to see what I can make it look like. I wanted to create a new platform sprite, so I whipped up a quick sprite; no problem.

 

Because I want the sprite to replace the existing platform that's already in the game, I went into the assets folder and removed the current platform.png. Then, I saved my new sprite into the assets folder and called it platform.png. My assumption was that phaser would load in the new asset instead of the old - Not the case. The original platform.png still renders, even though it is no longer in the assets folder.

 

I assume this is because of how Phaser caches assets to save memory - is that correct? And if so, how do I clear the cache, or reset it? I've browsed around on forums / the phaser docs, and I've found some relevant methods and answers, but because of my lack of experience with the framework I cannot seem to get anything to work.

 

I would imagine in game development, you sometimes start with a placeholder sprite, and as you continue to work you want to make the sprite look better, or different. So it would seem to me that there should be an easy way to do this.

 

Thanks for your input

 

Link to comment
Share on other sites

This is the browser cache at work, not Phaser. The best way to resolve it is to test with the Dev Tools open, and in the Dev Tools settings enable the 'Disable Cache when Dev Tools is open' option. Voila - no more cache issues.

 

Most of the times, even this isn't enough. What you sometimes have to do is directly access the URL to your resources (eg: localhost/assets/myimage.png) and refresh the page using CTRL+SHIFT+R there. This gets annoying sometimes

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...