我在一款完全显示在我的Galaxy Note 3上的应用程序上工作得非常努力。但是,它并没有在iPhone上显示,也没有在我测试的其他Droid上显示。我的问题是使用addChild(),然后调整它以适应屏幕。出于某种原因,当我添加背景(addBG();屏幕大小有效但是如果我将addChild加载到BG时,这在我的Note 3上很有效,但在iPhone或其他Android设备上却没有。
我的问题是我创建的screenX,screenY var。它们似乎与设备不同。或者它是一个“渲染订单问题”我不确定。如此有助于解决这个问题,以便在每部手机上看起来都很棒。我已经阅读了关于这个主题的一些内容,但它们令人困惑。我认为我的代码很接近,我希望,也许它只需要一个调整。 !
以下是iPhone上关于屏幕的镜头。看到白色不适合整个屏幕。
以下是我的Droid Note 3中的一个镜头。
在包中声明了Vars:
这不是我的完整代码,当然只是我认为相关的代码。
public var screenX:int;
public var screenY:int;
public function Main()
{
if (stage)
{
setStage();
addBG();
}
}
public function setStage()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
if (flash.system.Capabilities.screenResolutionX > stage.stageWidth)
{
screenX = stage.stageWidth;
screenY = stage.stageHeight;
}
else
{
screenX = flash.system.Capabilities.screenResolutionX;
screenY = flash.system.Capabilities.screenResolutionY;
}
}
这适用:addBG();
public function addBG()
{
theBG = new BG();
addChild(theBG);
theBG.width = screenX;
theBG.height = screenY;
}
这不是:addAbout();
public function addAbout()
{
About = new viewAbout();
About.width = screenX;
About.height = screenY;
theBG.addChild(About);
TweenMax.fromTo(About,1, {alpha:0}, {alpha:1, ease:Expo.easeOut} );
}
更新:还有一个更复杂的负载也是从按钮调用并具有相同的问题。我希望你能看到我想要做的事情的逻辑。首先将BG设置到设备,然后加载并调整内容大小以按比例适合加载的BG I.原因是,BG将被扭曲到不同的比例,这没关系,但内容不能。所以这里是将内容加载到BG然后内容到该容器中的示例。
public function addRosaryApp()
{
Rosary = new viewRosaryApp();
Rosary.width = screenX;
Rosary.height = screenY;
theBG.addChild(Rosary);
TweenMax.fromTo(Rosary,1, {alpha:0}, {alpha:1, ease:Expo.easeOut} );
contentRosary = new contentRosaryApp();
theBG.addChild(contentRosary);
contentRosary.width = screenX;
contentRosary.scaleY = contentRosary.scaleX;
contentRosary.x = screenX/2 - contentRosary.width/2;
contentRosary.y = menuBanner.height;
}
答案 0 :(得分:1)
您是否尝试过将孩子添加到舞台上,然后设置大小?这是我在addBG和addAbout
之间看到的唯一区别 About = new viewAbout();
theBG.addChild(About); // do this first
About.width = screenX; // then set width
About.height = screenY; // and height
答案 1 :(得分:0)
我认为你的问题可能与几件事情有关。 到目前为止,我对自己的设备(Ipad Air,iphone 4S,LG G2和Acer Iconia A500)的调查结果显示,唯一正确报告的设备尺寸是 stage.fullScreenWidth 和 stage.fullScreenHeight
1,Android报告 Capabilities.screenResolutionX 作为Android设备的LONG端。 然而,IOS设备会将设备的SHORT端报告给 Capabilities.screenResolutionX 。
第二,stage.stageWidth和stage.stageHeight似乎在Android和IOS上报告错误的大小。 事实上,如果你检查之前的 之后设置 stage.scaleMode 和 stage.align 之后的那么值将是完全不同(虽然Android几乎可以正确显示)。
我的建议是为您的应用设置基本大小(宽度和高度),然后将其与设备报告的实际stage.fullScreenWidth和stage.fullScreenHeight进行比较。这样你就可以得到一些很好的scaleratios用来扩展你的displayobjects。这就是我目前在我的应用程序上,它可以很好地扩展: - )