您如何为所有(或大多数)构建普遍使用Corona SDK映像?

时间:2014-05-27 17:49:59

标签: lua corona

我正试图在屏幕上放置图标,但无法想到为所有版本普遍执行此操作的方法。有没有可以帮助我的文件?目前,我已将它放置如下:

    local mapButton = display.newImage ("images/mapButton.png");
    mapButton.x = _W / 1.125;
    mapButton.y = _H / 6.5;
    mapButton.alpha = .25

    local theNorthTap = display.newRect(_W/3,_H/3.75,500,375);
    theNorthTap.alpha = 0
    theNorthTap.isHitTestable = true
    theNorthTap:addEventListener("tap", theNorthTap);
    function theNorthTap:tap(e)
        storyboard.gotoScene("theNorth",{
             effect = "slideLeft",
            time = "250"
        })
    end

对于Android版本来说这看起来很漂亮,但是对于Ipad或平板电脑版本显示屏幕有一半。

1 个答案:

答案 0 :(得分:1)

我将所有相对于display.contentWidth / display.contentHeight的位置。 我认为你的_W / _H等于那个但是以防万一..

例如,左上角的定位类似于:

object.x=display.contentWidth*0.25
object.y=display.contentHeight*0.25

如果你想要一个更精确的位置,请使用锚点进行调整,因此在这种情况下会出现左上角:

object.anchorX=0
object.anchorY=0
object.x=0 -- Or the border distance you want
object.y=0