For some reason I’ve suddenly started to have problems getting the letterbox scaling to work properly.
I use the same setting as usual, scaling the entire thing to 800x1300 using the following config.lua:
application = { content = { width = 800, height = 1300, scale = "letterbox", xAlign = "center", yAlign = "center", fps = 60, } }
I have always thought (and experienced) that this would create a virtual drawing area of 800x1300 pixels with black bars outside this (if necessary).
But with my last project I have obviously somehow messed this up. Please consider the following main.lua:
-- Content auto-scaled to 800 x 1300 \_W = display.contentWidth \_H = display.contentHeight print("Virtual screen size (" .. \_W .. " x " .. \_H .. ")") -- Draw background local bg = display.newRect(\_W/2, \_H/2, \_W, \_H) bg:setFillColor(0.3,0.6,0.2) -- Draw top bar 1 tb = display.newRect(0, 0, \_W/2, 80) tb.anchorX = 0 tb.anchorY = 0 tb:setFillColor(0.2,0.4,0.9,0.85) -- Draw top bar 2 tb = display.newRect(\_W/2, -50, \_W/2, 80) tb.anchorX = 0 tb.anchorY = 0 tb:setFillColor(0.9,0.4,0.2,0.85)
This snippet reports (correctly) that the virtual drawing area is 800x1300.
Then I fill the entire background with this line:
local bg = display.newRect(\_W/2, \_H/2, \_W, \_H)
And place a blueish top bar like this:
tb = display.newRect(0, 0, \_W/2, 80) tb.anchorX = 0 tb.anchorY = 0 tb:setFillColor(0.2,0.4,0.9,0.85)
Then I add a orange top bar, but this time I set the y position to a negative value (-50):
tb = display.newRect(\_W/2, -50, \_W/2, 80) tb.anchorX = 0 tb.anchorY = 0 tb:setFillColor(0.9,0.4,0.2,0.85)
To my surprise this was drawn outside of the letterbox (see attachment).
Is this really how this is supposed to work with the letterbox scaling? Is there a bug? Or is it me who have messed up (as usual :P )?