Sign in to follow this  
sta-ger

Warging "Texture added to the cache with an id [0] that already had an entry" when using Spritesheet.parse()

Recommended Posts

Hi,
I'm trying to build a Texture using PIXI.Spritesheet with manually loaded img and json.
 

baseTexture = new PIXI.BaseTexture(img);
pixiSpriteSheet = new PIXI.Spritesheet(baseTexture, json);
pixiSpriteSheet.parse(() => {
     console.log("Parsed");
});

 

If i do this several times with different images I'm getting a warning message: "Texture added to the cache with an id [0] that already had an entry".

After some investigations I've found that parsed textures are always adding to cache with frame idx as a key.

Spritesheet.prototype._processFrames = function _processFrames(initialFrameIndex) {

...

_.Texture.addToCache(this.textures[i], i);

...

}

 

Every time when parsing a new sprite sheet the cached textures will be overwritten by new with the same index.

Looks like any texture must have a unique ID when caching but it doesn't... Is it a normal behaviour or am I doing something wrong? Is it possible to disable this warn message even if this is normal?

Share this post


Link to post
Share on other sites

In that case, index is name of the texture inside spritesheet. If you have that kind of problems, throw the cache out, do "PIXI.utils.clearTextureCache" or something ( i dont remember), because that cache exists only for "from" and "fromFrame", "fromImage" methods, pixi doesnt actually need it :)

Share this post


Link to post
Share on other sites
On 3/15/2019 at 6:49 PM, ivan.popelyshev said:

In that case, index is name of the texture inside spritesheet. If you have that kind of problems, throw the cache out, do "PIXI.utils.clearTextureCache" or something ( i dont remember), because that cache exists only for "from" and "fromFrame", "fromImage" methods, pixi doesnt actually need it :)

Cool! Throwing out the cache was helpful, thanks a lot! 🙂

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.