0

我不知道我是否在做一些愚蠢的事情,或者 Corona 模拟器中是否存在错误。当我编写以下代码时:

rect = display.newRect(0, 0, 100, 100)
rect.anchorX = 0
rect.anchorY = 0
rect.x = 0
rect.y = 0

这只是将 100x100 正方形的锚点设置到其左上角,并将位置设置为 0,0。这应该使正方形紧贴角落,但它会产生this。它在 Y 轴上总是有点太低了,但 X 轴工作正常。有没有人可以解决这个问题?

4

1 回答 1

1

使用我的 Corona 模拟器(build 2016.2992)代码按预期工作。

main.lua

---------------------------------------------

local rect = display.newRect( 0, 0, 100, 100)
rect.anchorX = 0
rect.anchorY = 0

首先检查你的 config.lua 文件。我认为这取决于显示分辨率。例如,在letterbox模式下,您的设备上可能会出现“黑条”,其纵横比与您的内容纵横比不同。阅读有关 Corona 文档的更多信息。

下面是我正在使用的 config.lua 文件中的代码

config.lua

---------------------------------------------

--calculate the aspect ratio of the device
local aspectRatio = display.pixelHeight / display.pixelWidth
application = {
   content = {
      width = aspectRatio >= 1.5 and 800 or math.floor( 1200 / aspectRatio ),
      height = aspectRatio <= 1.5 and 1200 or math.floor( 800 * aspectRatio ),
      scale = "letterBox",
      fps = 30,

      imageSuffix = {
         ["@2x"] = 1.3,
      },
   },
}
于 2016-11-20T09:59:00.863 回答