shashank Posted September 20, 2017 Share Posted September 20, 2017 I have loaded SpriteSheet using json. Like this below. const loader = new PIXI.loaders.Loader(); loader.add('bunny', 'data/bunny.png') .add('spaceship', 'assets/spritesheet.json'); loader.load((loader, resources) => { }); I want to remove all the TextureCache which was loaded using this spritesheet.json only. I have tried. PIXI.Texture.removeFromCache("spaceship"); PIXI.Texture.removeTextureFromCache("spaceship"); But in PIXI.TextureCache names of all the spriteFrame were included there. And still i am able to use image form frame. Using this. var bgSprite2 = PIXI.Sprite.fromFrame("ship1"); bgSprite2.anchor.set(0.5, 0.5); var pos = {x: 300, y: 200}; bgSprite2.position.set(pos.x, pos.y); stage.addChild(bgSprite2); I want to remove all the entries of spriteFrame in TextureCache and i want to load new set of spriteFrame. I am doing this because i have spritesheet animations of two diffrent spaceship but the individual symbol name of both spaceship are same. Please help. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 20, 2017 Share Posted September 20, 2017 I hate cache problems, pixi cache is not user-friendly You have to understand that "remove from cache", "free the videomemory" arel different things, and "destoy the texture" includes all of them. There's also huge difference between Texture and BaseTexture. Make sure you understand all of it before you write that code. You have to iterate through all textures of that spritesheet and remove them from cache, then remove baseTexture: let baseTex = null; for (key in spaceship.textures) { Texture.removeFromCache(spaceship.textures[key]); //or just 'key' will work in that case baseTex = spaceship.textures[key].baseTexture; //they all have same base texture } BaseTexture.removeFromCache(baseTex); Also make sure you remove it from loader, just remove all things : `loader.reset()` or remove "spaceship" and "spaceship_image" from resources list. shashank 1 Quote Link to comment Share on other sites More sharing options...
shashank Posted September 20, 2017 Author Share Posted September 20, 2017 Thanks ivan.popelyshev i will do as you said. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.