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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.