-
-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Size and color is different on Android #1673
Comments
This depends on the different density of the screen pixels. When FullHD resolution fits into a smartphone - an individual pixel will look very shallow on it. You need to use a variable with a relative square size or try Capabilities.screenDPI. |
Exactly, even if the window/app may seem the same size on your screen, Galaxy S6 from your screenshot has 1440 x 2560 pixels resolution so obviously the squares are smaller. I'm not sure why the order is different though. Have you tested on real android device or just using the emulator? |
Thank you folks. And there is some standard way/library to handle DPI scale? How do you usually overcome this? It's a very common problem people ran into I guess. Or aren't HaXe/OpenFl used for mobile? I'll setup a real device to check the colors, brb. |
On native, we use the BGRA color order, which might not be supported properly in the emulator there. You should be able to check |
Right, I could get device DPI by By the way, colors are ok on real device. |
Ok, cool, so: size = dp(100); And: private function dp(value: Float): Float
{
return value * scaleFactorFor(Capabilities.screenDPI);
}
private function scaleFactorFor(dpi: Float): Float
{
var factorMap: Map<Int, Float> = [
160 => 1.0,
240 => 1.5,
320 => 2.0,
480 => 3.0,
640 => 4.0
];
for (density in factorMap.keys()) {
if (dpi <= density) {
return factorMap[density];
}
}
return 6.0;
} The adventure for tomorrow then will be to debug what f... happen with the window when changing from portrait to landscape. It messes it in a way that even when bring back to portrait it doesn't looks the same anymore: |
AHA! Did the trick: First Then add a stage.addEventListener(Event.RESIZE, resize, false, 0, true);
stage.addEventListener(Event.CHANGE, resize, false, 0, true);
resize(null); And update stage.window.width = stage.stageWidth;
stage.window.height = stage.stageHeight; |
Very, very cool platform to work on. |
From left to right: flash, android, html5.
Why does the elements on Android version looks smaller and the RGB order doesn't seams the same?
Main.hx
:project.xml
:The text was updated successfully, but these errors were encountered: