Jump to content

Managing HD and SD assets WITHOUT Pixi.Loader


ikkleh
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...