spassvogel Posted September 26, 2020 Share Posted September 26, 2020 So in my game I have multiple sprite sheet atlasses representing the animated characters. Those characters all have animation frames, eg: "walk1", "walk2", "idle1" etc. I load them via the shared loader. I want to be able to load any of those character spritesheets into an AnimatedSprite and tell them to play the frames "walk1", "walk2". However it seems pixi overrides the textures Texture added to the cache with an id [walk1] that already had an entry And all my characters are using the frames from the latest loaded spritesheet ? Is there some way around this? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 26, 2020 Share Posted September 26, 2020 yes, dont use pixi cache (from), use "loader.resources['atlasXXX'].textures". https://github.com/kittykatattack/learningPixi Quote Link to comment Share on other sites More sharing options...
spassvogel Posted September 28, 2020 Author Share Posted September 28, 2020 @ivan.popelyshev That works in the sense that the textures are no longer overridden. I still see the console spammed with the message Texture added to the cache with an id [walk1] that already had an entry is there some way to suppress this? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 28, 2020 Share Posted September 28, 2020 > is there some way to suppress this? yes, find in pixi sources how to turn this thing or whole texture cache off. probably through hacking Quote Link to comment Share on other sites More sharing options...
spassvogel Posted September 29, 2020 Author Share Posted September 29, 2020 I see in https://pixijs.download/v4.8.6/docs/core_textures_Texture.js.html there is a @if DEBUG statement. Looks like some sort of compiler directive. Can you tell me a bit how that works? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 29, 2020 Share Posted September 29, 2020 (edited) honestly, i dont know if it works "PIXI.Texture.addToCache = ... " , just override function without if. You can even make it empty, we dont need cache, right? Edited September 29, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
spassvogel Posted September 29, 2020 Author Share Posted September 29, 2020 Well no I'm actually very happy with the global pixi loaders' cache. In my setup (using @react-pixi) pixi is set up and torn down multiple times (because components get unmounted etc). So it's very nice that the sprites are kept in cache. Perhaps I am alone in this but I think sprites loaded through a spritesheet atlas should get some sort of encapsulation, maybe just by prefixing with the atlas name or something. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 29, 2020 Share Posted September 29, 2020 Good idea, maybe it was written somewhere, but i cant find it :( How to do a PR: https://github.com/pixijs/pixi.js/tree/dev/packages/spritesheet/src , change spritesheetLoader that way it passes extra param from "resource.metadata" to spritesheet constructor or extra param before parse(). Change spritesheet, add prefix param and use it in addToCache 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.