gluckgames / pixi-packer

Fast and flexible texture packer for PIXI.js
MIT License
40 stars 6 forks source link

'Global scale' constant / Container #44

Closed kulabros closed 7 years ago

kulabros commented 7 years ago

Hi there, I have one question, about different assets/stage scale settings and behaviour. I have PIXI app, by default 1280x666px. Assets - graphics for thi game, and animations - created in Animate CC and exported using pixi-animate, are made for this resolution. I'd like to have three stages of final export - desktop, mobile and retina. So, desktop would be scale 1, mobile halfsized - 0.5 and retina double size - 2. If i I create spritesheets, retina ones, with resolution set to 2, have the same size, as the default one. Do I need to create some -@x2 files in this case? .. Because, when I load this assets to scene with default size, they're two times smaller.. So I'm thiinking about something like extending Container, with global scale constant, that would be used for each instance, and exported animations from Animate will be on place in this case. Another situation would be, if my assets were HD, and desktop or mobile is just downscale only, that would work fine, as my default and mobile now. It is not neccessary, to create double sized retina version in my case now, but I'd expect, if I write line with resolution 2 in packer, export will be double sized. Or not? What would be best setting in your opinion for desktop/mobile/retina game assets? Thanks for input and ideas, I can write some further info if needed. My settings looks like this:

"scales": { "desktop": {"scale": 1, "resolution": 1}, "mobile": {"scale": 2, "resolution": 0.5}, "retina": {"scale": 0.5, "resolution": 2} },

Desktop and mobile works as expected, animations created in Animate are in place. If i use retina version, everything is twice smaller.. If I pass resolution pixi app option, with devicePixelRaton, assets (bitmaps) resolution is good size, but positions are double.. Have you think or handle this situtation? Thanks

marekventur commented 7 years ago

There's no support for @x2 files, the idea is to create all assets for the largest scale and then let pixi packer handle the downscaling. So in your case just export everything as "retina" and use this config:

"scales": {
"retina": {"scale": 1, "resolution": 2}
"desktop": {"scale": 0.5, "resolution": 1},
"mobile": {"scale": 0.25, "resolution": 0.5},
},

We don't have the "mobile" level in our games, but the other two work without problems for us. Let me know if there are any other problems.

kulabros commented 7 years ago

Ok, great, sounds good, thank you for explanation, I'll do it like this. In my case, 1280x666 is in between desktop/mobile, so I'll discuss with gfx dep., that next renders, will be in higher resolution (maybe 1920x999 - for the retina, desktop keep my 1280x666 and mobile case, maybe some very low end, half.. Idea in my case is to have still same pixi app size, resizer settings etc. So yes, solution would be as you wrote, and maybe with higher resolution by default.

Just last question, how do you think about performance on mobiles - iOS/Android ... Is canvas element size (pixi app + resolution) size the value, the value, that affects performance, or is better to keep still same 1:1 canvas element size and use css scale? (as I do in my case)

marekventur commented 7 years ago

I don't know much about the performance side of the actual renderer, sorry. You might have to ask on the PIXI repository or set up some benchmarks.

Can I close this issue?

kulabros commented 7 years ago

Ok, of course, thank you :)