2016-11-20 37 views
0

我不知道我是在做一些愚蠢的事情還是在Corona模擬器中有一個錯誤。當我寫下面的代碼:電暈模擬器的錨點Y

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軸功能正常。有沒有人有這方面的修復?

回答

1

與我的電暈模擬器(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, 
     }, 
    }, 
} 
+0

非常感謝你,我會考慮這個! – EvilLemons