Leveldesign and the new config.lua

Hello,

I am using the modernized config.lua for a game that I am making:

--calculate the aspect ratio of the device local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 30, imageSuffix = { ["@2x"] = 1.3, }, }, }

I keep an external file where I set x and y positions of objects that appear on the screen. Like so:

l6= { {x=400, y=420, n=1}, {x=400, y=550, n=1} }, l7= { {x=150, y=220, n=3}, {x=320, y=450, n=3} },

I though if I use the new config.lua x=400 would result in a centered object, on all devices. However on the iPad it’s slightly moved to the left. Whereas it’s perfectly centered on all iPhones.

Is there a better way to do this? How do you design your levels?

Thanks so much in advance,

Phil

Hi Phil,

Because of the variable config.lua you’re using, the content area won’t always be 800 on different devices. So, if you want to determine the exact center of the content area with a variable content size, you should use the following APIs:

[lua]

display.contentCenterX

display.contentCenterY

[/lua]

And if you want to determine the overall width/height in your code at whatever point:

[lua]

display.contentWidth

display.contentHeight

[/lua]

Hope this helps,

Brent

Hi Phil,

Because of the variable config.lua you’re using, the content area won’t always be 800 on different devices. So, if you want to determine the exact center of the content area with a variable content size, you should use the following APIs:

[lua]

display.contentCenterX

display.contentCenterY

[/lua]

And if you want to determine the overall width/height in your code at whatever point:

[lua]

display.contentWidth

display.contentHeight

[/lua]

Hope this helps,

Brent