Sakthivadivel Posted June 10, 2017 Share Posted June 10, 2017 Hi Guys, I have developed a game using phaser.js with two states.Which loads the assets every time when I restart state or go to next level.It leads to memory problem.I want to block loading assets if it is already exist in game cache.How to do check all the assets or available in cache? Please any one help me. Thanks, Sakthi Link to comment Share on other sites More sharing options...
Skeptron Posted June 10, 2017 Share Posted June 10, 2017 I'm pretty sure it's the default behaviour of the browsers, not to load an asset that is already in cache. I would say you shouldn't have anything specific to do. Link to comment Share on other sites More sharing options...
aapo Posted June 11, 2017 Share Posted June 11, 2017 I believe @Sakthivadivel isn't talking about the browser cache, but Phaser's asset cache. You can use Cache.checkKey() to check for the existence of a key in a cache. Something like: game.cache.checkKey(Phaser.Cache.IMAGE, 'enemy') game.cache.checkKey(Phaser.Cache.SOUND, 'explosion') The method returns true if the key is found in the cache and false if it's not Link to comment Share on other sites More sharing options...
Sakthivadivel Posted June 28, 2017 Author Share Posted June 28, 2017 Hi Skeptron and aapo , Thanks,for your reply...You are correct aapo.I don't want to load assets that are already exist in cache.I used the Cache.checkKey() method you mentioned above and it is working fine. Thanks a lot, Sakthi. Link to comment Share on other sites More sharing options...
Recommended Posts