Corona模拟器中的锚点问题Y

我不知道我是在做一些傻事还是Corona模拟器中有一个bug。当我写下面的代码时:

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

这只是将一个100x100的矩形的锚点设置为左上角,并将位置设置为0,0。这应该让矩形在角落里很贴合,但实际上它产生了这个。它在Y轴上总是有点太低了,但在X轴上函数是正确的。有人有解决方法吗?

点赞
用户7026995
用户7026995

通过我的 Corona 模拟器(版本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

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

-- 计算设备的宽高比
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-20 09:59:00