我无法判断我是在做傻事还是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轴正常工作。有人有解决方法吗?
答案 0 :(得分: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 documentation的更多信息。
以下是我使用
的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,
},
},
}