How do I check if an image has already been loaded?

Sorry if it has already been asked, but I couldn’t find it

this.textures.exists()

Thanks for you answer, samme :+1:

Strangely enough, though, it always reports false in my case.
I’m loading images like this:

scn.load.svg(assetId, assetPath, { width: w, height: h });

where assetId is the name of the file without the extension

I’m creating a bunch of containers with some images with the same texture inside and I wanted to avoid even trying to load them. Iknow this sort of a micropotimization that won’t make much, but I’m also trying to understand the framework in the process.

If I make this on the load() function of the module that’s creating the guts of the containers

console.log(scn.textures.exists(assetId));

It always reports false

Is it because the entry on the texture list is not created until the texture is actually loaded, right?
Am I correct to assume the TextureManager is going to reject loading again something with the same key or path?

Mmm, never mind :zipper_mouth_face:.

I can see it’s only loading every image once on the devtools Network panel of the browser

Pardon me, but this means that phaser has support for SVG sprites with animation?

It does support svg images, so you can set up animations using svg images. It’s not documented, but once you have your SVGs loaded and with ids like svg_Id_0, svg_Id_1, …, svg_Id_n, … you can create animations using somthing like:

scene.anims.create({
  key: animationId,
  frames: [
    //...
    { key: svg_Id_n }
    //...
  ]
);

In general you are supposed to use a sprite-sheet or image-atlas to create animations, but in the case of SVGs, there’s no use for them, or at least it doesn’t make so much sense to use them, as you are not going to save so much bandwidth. So I would’t bother even trying to create them. I just load every frame as a single image