Find out if key exists in cache?

Hi Everyone!

Does anyone know how to find out if a specific key exists in the cache?

I’ve tried this: Phaser.Cache.BaseCache.exists("assetKey") - but get an error.
It looks like it should work, but maybe I’m accessing it incorrectly?
(Phaser 3 API Documentation - Class: BaseCache)

this.cache.audio.exists('key') etc.

Thanks @samme!

That works, although I discovered that images are in a separate location:

this.cache.game.textures.list

So I was able to check for an existence of an image key like this:

if (!this.cache.game.textures.list["imageKey"]) {...

this.textures will do it.

1 Like