Still problem on Screen scale: contentWidth vs actualContentWidth

I have read a lot of explanation about screen scaling.

But still I can’t replicate what is being explained.

What am I doing wrong ?

My corona build is 2020.3580

My config.lua

settings = { content = { width = 320, height = 480, xAlign = "center", yAlign = "center", scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, ["@4x"] = 4, }, }, …

So I expect to get these values in the app

display.contentWidth == 320

display.contentHeight == 480

but it doesn’t work that way. I get different values depending on whether you use the simulator or my LG V30 phone.

My code app:

… local interlinea= display.actualContentHeight/10 local testTx1 = display.newText( btnGroup, "display.actualContenWidth " .. display.actualContentWidth, display.contentCenterX, interline) local testTX2 = display.newText( btnGroup, "display.contentWidth " .. display.contentWidth, display.contentCenterX, interline\*2 ) local testTx3 = display.newText( btnGroup, "display.actualContentHeight " .. display.actualContentHeight, display.contentCenterX, interline\*3 ) local testTx4 = display.newText( btnGroup, "display.contentHeight " .. display.contentHeight, display.contentCenterX, interline\*4 ) …

My result on simulator Android (xhdpi) 1536x2048

display.actualContenWidth    1536

display.contentWidth             2048

display.actualContentHeight  2048

display.contentHeight            1536

My result on LG V30

display.actualContenWidth    1080

display.contentWidth             1080

display.actualContentHeight  2034

display.contentHeight            1920

if I try to draw a rectangle that covers the maximum of the screen without stretch, as per “letterbox”, I get this on simulator

[sharedmedia=core:attachments:8894]

and on my LG 30.

[sharedmedia=core:attachments:8895]

What am I doing wrong ?

Thank you!!

Renato

You seem to be mixing build.settings and config.lua.

In your config.lua file, all you need to enable scaling and dynamic image selection is:

-- For more information on config.lua see the Project Configuration Guide at: -- https://docs.coronalabs.com/guide/basics/configSettings application = { content = { width = 320, height = 480, scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, ["@4x"] = 4, }, }, }

That settings  table of yours belongs to build.settings. Since you’ve placed the  application table inside  settings table, it isn’t where it is supposed to be and so Corona can’t find it.

!! was so simple!!

thank you, seems to works!

Renatp

You seem to be mixing build.settings and config.lua.

In your config.lua file, all you need to enable scaling and dynamic image selection is:

-- For more information on config.lua see the Project Configuration Guide at: -- https://docs.coronalabs.com/guide/basics/configSettings application = { content = { width = 320, height = 480, scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, ["@4x"] = 4, }, }, }

That settings  table of yours belongs to build.settings. Since you’ve placed the  application table inside  settings table, it isn’t where it is supposed to be and so Corona can’t find it.

!! was so simple!!

thank you, seems to works!

Renatp