brean Posted May 26, 2015 Share Posted May 26, 2015 Hi PIXI-community, Let us assume we have 2 JSON-file based spritesheets (e.g. game.json and ui.json). Both have same names for some of their textures (e.g. "button-up-skin", "button-down-skin" etc. One sprite has the Button for the base game UI, the other one a clearer button for the level editor).In the spritesheetParser the key used to store the texture in the TextureCache is the same for both, so whatever image loads second overrides the texture. Can I access the texture somehow different then the global texture cache?Can I get the image from the texture cache and save it somewhere else before the other image gets loaded?Is there a way to prefix the name so they get both stored in the cache?Or do I have to do something else (e.g. rename the textures in my spritesheet, extend spritesheetParser.js so it codes the name of the file loaded into the name of the texture)? Quote Link to comment Share on other sites More sharing options...
CinkoNaap Posted May 27, 2015 Share Posted May 27, 2015 Hey, you can make sure that your frames names are unique at spritesheets export stage. In smaller to medium projects that's fine approach. Otherwise create your own parser, and populate PIXI.utils.TextureCache the way you want. Just do not forget that nesting frames in "namespaces" will require overriding all fromFrame functions. Marcin Quote Link to comment Share on other sites More sharing options...
xerver Posted May 27, 2015 Share Posted May 27, 2015 If you are using the loader, then just use the loader. As I mentioned here: http://www.html5gamedevs.com/topic/14524-v3-access-cached-texture-by-name/ The loader already gives you access to everything you load, by the names you load it as. When you load your ui.json spritesheet you will be able to look in the ui.json resource and see a textures property with all the textures you loaded. Nothing makes you use the global TetureCache, it is just there for the silly convience .fromX() methods. brean 1 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.