Jump to content

Load assets only if it is not exist in cache


Sakthivadivel
 Share

Recommended Posts

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

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

  • 3 weeks later...
 Share

  • Recently Browsing   0 members

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