Kraghen

Checking for images already loaded with Loader()

Recommended Posts

Hi.

I load a bunch of image files into my app with Loader:

let loader = new PIXI.Loader();
loader.reset();
 
loader
.add(pinImagePath)
.add(whiteCircle24Path)
.add(whiteCircle64Path)
.add("images/crosshair.png");
loader.load(setup)

 

The PIXI app is part of a larger HTML application and it may get initiatet and destroyed multiple times. 

My problem is when i load the app the second time i get warnings that the Texture already have en entry:
"Texture added to the cache with an id [images/circle24.png] that already had an entry"

I can see the image is already present in the texture Cahe

PIXI.utils.TextureCache[images/circle24.png] 

But using Loader i would like to get the texture from Loader.resources[], but that one is empty if i dont load it again...?

 

Share this post


Link to post
Share on other sites
20 hours ago, jonforum said:

did you clear before ?

PIXI.utils.clearTextureCache();

No. That might be the way... 

But whats the purpose of the cache if I have to clear it all the time?

Seem like I can only load cached images when using fromImage() ...

In other words, how do I load cached images when using Loader.resources ?

let texture = PIXI.loader.resources["image"].texture; // does not look in TextureCache

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.