Tumetsu Posted August 13, 2016 Share Posted August 13, 2016 I'm building my first Pixi game and working on basic services for asset management. My game should support few different resolution asset packs. Pixi handles this fine with resolution values and scaling. Next part I'm working on is to reload higher definition assets when required. Lets say that player starts game on 800x500 embedded window but presses full screen toggle. In this case I'd like to load HD assets on background and then replace the SD assets with newer ones once loading is ready. Before implementation I'd like to know if there is any existing mechanism in Pixi for this kind of operation? Or if not, should I know something specific about Pixi's texture handling to avoid some pitfalls? My current idea is as follows: When user moves to HD mode, trigger reloadAssets event, which kicks of my AssetLoader which loads the set of resources I require at the moment. Loader stores the names and textures to a map in AssetStorage -service. Once this is finished, an updateAssets event is broadcasted. Each Sprite can listen this event and they will update their texture from my AssetStorage -service. The reason I'm slightly insecure about my design is because I don't know exact inner workings of Pixi's resource management. For example does Pixi clear assets automatically, which might mess up my AssetStorage -service? What exactly I need to do when I reload new versions of assets especially regarding the old assets?BaseTexture seems to have update() function, can I sue it for this case? I'm reading about this stuff but decided to drop a question here since these are things I couldn't yet find any clear examples. Also, I'm afraid I'll implement something which is already done better in Pixi Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 13, 2016 Share Posted August 13, 2016 Better to change Textures themselves: change their baseTexture and frame. That way you wont have to notify sprites. In most cases you wont even have to change frame/trim/crop things, they are the same for HD. Don't forget to scale your stage accordingly that pixel still stays 1:1. Also its better not to change "renderer.resolution" on fly. There are many things that can go wrong, but the main idea is: 1. coordinates of sprites must stay the same 2. coordinates in textures (frame/crop/trim) better to stay same. At least width height are same, multiply texture resolution and not its width/height Summary: Learn how Texture/BaseTexture work. Modify Textures and not sprites for it. Quote Link to comment Share on other sites More sharing options...
Tumetsu Posted August 13, 2016 Author Share Posted August 13, 2016 Alright, I think I tried something like that but didn't figure to modify my existing textures' baseTextures. Thanks. Btw, is the TextureCache in PIXI in state of flux atm? I keep finding mentions that it should be in utils, but on Pixi4 rc I found it from TextureManager which I couldn't find from docs. Quote Link to comment Share on other sites More sharing options...
mspanish Posted March 11, 2017 Share Posted March 11, 2017 Hello guys - is there a prebuilt or easy way to select the spritesheet to load based on resolution? I was going to make a function that switches things out if the resolution changes, or is above or below a certain threshold - I guess I'd just replace the spritesheet already loaded for another? Is there something more elegant than a switch statement in my scene loader that checks the resolution and if HD, loads the @2x spritesheet instead of the regular one? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 11, 2017 Share Posted March 11, 2017 This thing has it : https://github.com/pixijs/pixi-compressed-textures/ , just look at @1x @2x management, ignore ".dds" stuff Quote Link to comment Share on other sites More sharing options...
Ishaan Posted February 26, 2019 Share Posted February 26, 2019 Hello, Did we have any solution for it in Latest PIXI V4? I want to switch images to higher quality one on runtime as lazy loading one. Is it possible? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 26, 2019 Share Posted February 26, 2019 Nope, not from package, not from plugins. People who own those solutions dont share them. You have to do it on your own, maybe share later. Quote Link to comment Share on other sites More sharing options...
botmaster Posted February 26, 2019 Share Posted February 26, 2019 It's not as hard as it seems, our system handles from 0.25 to x3 resolution. The basic idea is > resource reference by resolution > get reference in app according to resolution. The resource reference can include scale and dimension, etc ... Stronger system define a target resolution and go through references until it finds the closest match. eg. target is 0.5, system tries to find a 0.5, then a 1, then a 2, etc .. until it finds one. here's an example of what we do in our apps, it's all plugged to a CDN. An asset can be defined 5 times with different density but at the end we only get one in app. new BitmapResource('contextresources/default_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 2); new BitmapResource('contextresources/low_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 1); new BitmapResource('contextresources/ultra_low_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 0); ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 26, 2019 Share Posted February 26, 2019 1 hour ago, botmaster said: It's not as hard as it seems, our system handles from 0.25 to x3 resolution. The basic idea is > resource reference by resolution > get reference in app according to resolution. The resource reference can include scale and dimension, etc ... Stronger system define a target resolution and go through references until it finds the closest match. eg. target is 0.5, system tries to find a 0.5, then a 1, then a 2, etc .. until it finds one. here's an example of what we do in our apps, it's all plugged to a CDN. An asset can be defined 5 times with different density but at the end we only get one in app. new BitmapResource('contextresources/default_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 2); new BitmapResource('contextresources/low_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 1); new BitmapResource('contextresources/ultra_low_density/resource_7571.png', 'bitmap', 'TL', 1024, 688, 0); How is your flash coming, buddy? Mine will be completed in 6 months, i think. We've got ALL vector graphics operations, and ALL BLUR-RELATED FILTERS. All blendModes, FILTER CACHE, many other things. botmaster 1 Quote Link to comment Share on other sites More sharing options...
botmaster Posted February 26, 2019 Share Posted February 26, 2019 What do you mean? You got a flash/javascript framework coming up? < interesting. Mine is doing fine but it's not for public release (missing too many things but working right for us) ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
botmaster Posted February 28, 2019 Share Posted February 28, 2019 Seriously I wanna know more, what will you have completed in 6 months? Is it a framework? 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.