ikkleh Posted February 20, 2018 Share Posted February 20, 2018 Hi all, My project manages asset loading through it's own loading system (I'm not using the Pixi Loader) and I'm a little confused about using SD and HD assets. I export 2 versions of each sprite sheet (from Texture Packer) - 1 SD size (e.g. sheet.png) and 1 HD size (e.g. [email protected]). My loading system then checks window.devicePixelRatio and loads the correct asset accordingly (SD for dpr=1 and HD for dpi > 1 etc). However, I'm a little confused as to setting the baseTexture resolution to tell the renderer the scale of the texture I know the Pixi loader does this, but how to I set this correctly according the the DPR without using the loader? Thanks in advance! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 20, 2018 Share Posted February 20, 2018 Congratulations on setting up custom loader with pixi! If you want, you can build pixi without resource-loader to make js even smaller. Please look inside pixi sources and just figure out everything related to resolution: https://github.com/pixijs/pixi.js/blob/dev/src/core/textures/BaseTexture.js#L17 That's how loader does it: https://github.com/pixijs/pixi.js/blob/dev/src/loaders/textureParser.js#L11 , https://github.com/pixijs/pixi.js/blob/dev/src/core/textures/Texture.js#L438 , https://github.com/pixijs/pixi.js/blob/dev/src/core/utils/index.js#L149 Prepare to debug pixi. I recommend to use just "pixi.js" and not minified version and no source-maps, because they're kinda shifted a few lines and i still dont know why. Quote Link to comment Share on other sites More sharing options...
ikkleh Posted February 20, 2018 Author Share Posted February 20, 2018 Thanks, I'll take a look! Quote Link to comment Share on other sites More sharing options...
ikkleh Posted February 20, 2018 Author Share Posted February 20, 2018 Another question - should Pixi automatically scale the sprites according to the resolution? It's just that I'm seeing some of my sprites at 1/2 the size they should be ... Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 20, 2018 Share Posted February 20, 2018 Make sure renderer has same resolution. Dont just set it, it has to be passed into constructor, its difficult to change it in runtime! Make sure you use "renderer.screen.width" or "app.screen.width" instead of "renderer.width" everywhere. When you load 512x512 image with @2x resolution , texture width and height should be 256. Check that parameter for textures that you have problem with. 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.