缩放与八哥Android设备造成了一些布局问题 [英] Scaling for Android devices with starling causing some layout issues

查看:195
本文介绍了缩放与八哥Android设备造成了一些布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是多分辨率技术排名第三的是写在这文章

I'm using multi resolution technique number three as written in this article

和确定的比例因子和舞台大小,我用这块code最初是由杰夫:

and to determine the scale factor and stage size, I'm using this piece of code originally written by Jeff :

        if (Capabilities.screenDPI >= 200) {
            if (Capabilities.screenDPI >= 280) {
                AssetFactory.contentScaleFactor = 2;
            }
            else {
                AssetFactory.contentScaleFactor = 1.5;
            }
        }
        else {
            AssetFactory.contentScaleFactor = 1;
        }

        var mViewPort:Rectangle = new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight);

        mStarling = new Starling(Startup, stage,mViewPort);
        mStarling.stage.stageWidth = stage.fullScreenWidth /  AssetFactory.contentScaleFactor;
        mStarling.stage.stageHeight = stage.fullScreenHeight / AssetFactory.contentScaleFactor;

然后,我用这个比例系数,以确定哪些大小的资产我需要挑选。

Then I use this scale factor to determine which sized assets I need to pick.

所以,现在,我有我STRETCH时到舞台宽度和尺寸方面的背景。这种技术的工作原理伟大的,当我测试与大多数设备,但后来我们有像巴恩斯和诺布尔的Nook Color器件。

So now, I have a background which I strech to stage width and size. This technique works great when I'm testing with most devices but then we have devices like the Barnes and Noble Nook Color.

该器件具有600x1024 170 dpi的分辨率。这意味着它会挑最小的资产(小320x480),它STRETCH时为600x1024。这ofcourse是pixalated。如何克服这个问题的任何想法?

The device has a resolution of 600x1024 with 170 dpi. This means that it's going to pick the smallest assets (320x480) and strech it to 600x1024. Which ofcourse is pixalated. Any ideas on how to get over this issue?

我还附上一个测试应用程序,它显示了问题的详细的https: //dl.dropbox.com/u/2192209/scaling%20test.zip

I'm also attaching a test application which shows the issue in detail https://dl.dropbox.com/u/2192209/scaling%20test.zip

推荐答案

什么工作对我来说最好的,到目前为止不结垢八哥的视口都没有。它应该始终保持底座尺寸(小320x480)。

What worked for me best so far is not scaling Starling's viewport at all. It should always remain the base size (320x480).

那么您对质地应为多大比例因子。传递一个比例因子 - 创建纹理时,它的椋鸟的内置功能。 这意味着,如果你的舞台是640×960,您的比例因子是2。你的图像(位图对象),将有小320x480(全屏,1:1与舞台大小),实际的屏幕尺寸,但它的质地(装资产的BitmapData )将两倍大(640×960,1:1与手机大小)

Then you have a scale factor about how big the texture should be. It's a built feature of Starling when creating a texture - passing a scale factor. What this means is that if your stage is 640x960, your scale factor will be 2. Your image (Bitmap object), will have ACTUAL SCREEN size of 320x480 (fullscreen, 1:1 with stage size), BUT it's texture (loaded asset BitmapData) will be twice as big (640x960, 1:1 with phone size).

有关更容易理解 - 斯塔林(小320x480)的阶段将扩大规模,以适应手机的分辨率(320 - > 640)。但是你的图像将被缩小以适合舞台(640 - > 320)。所以,你得到完全正常的图像。

For easier understanding - the stage of Starling (320x480) will be scaled up to fit your phone's resolution (320 -> 640). But your images will be scaled down to fit in the stage (640 -> 320). So you get perfectly normal images.

这可以帮助你维持阶段固定大小。这是真正有用的,否则这将是很难定位对象 - 如果你想在中间的对象,它有时160,有时是320,等等。这意味着你总是要设定的位置/使用计算的大小,这是一个超载。

This helps you maintain fixed size of stage. It's really helpful, because otherwise it would be hard to position objects - if you want the object to be in the middle, it's sometimes 160, sometimes 320, etc. This means you always have to set position/size with calculations, which is an overload.

希望帮助!

编辑:只记得一个网站,我来确定我的主要尺寸与资产比率:的http:// screensiz。 ES /电话

edit: Just remembered of a site I've used to determine my main size and assets ratios: http://screensiz.es/phone

这篇关于缩放与八哥Android设备造成了一些布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆