Modernizing the config.lua - Rob Miracle article

@Rob, Yea I got confused by your above post

“Keep in mind, the config.lua is presented in “Portrait” mode.”

So - panicked and thought I’m using" Landscape" mode! Lolz.

fwiw, i would suggest replacing the calls to math.ceil() with math.floor() instead, if you want to preserve the specified dimension exactly as the “fit” axis, and force the other (calculated) axis to be the letterboxed one.  (rIght now, it actually does the opposite, except in those cases where no fractional coordinates would occur at all, like 4:3 aspect, where choice of floor/ceil makes no difference)

That is, say on a 16:9 aspect device (say 1920x1080), if you set width to a fixed 800, then calculate height using math.ceil() you’ll get that 1423 value.  But that’s a fraction of a pixel too much to actually fit that height into the display’s aspect ratio at the same scale as 800 would fit width.  So scale will be slightly reduced so as to fit the larger height instead, and your width will end up a tiny bit letterboxed.  (about 800-and-a-half pixels) if you check display.actualContentWidth afterwards.

Which seems like the opposite result you were going for.  (you didn’t preserve your specified 800 width)

If you use math.floor(), then you’ll instead request a height of 1422, which will be just a tad too short, (which is what you’d want, in order to guarantee which axis fits, and which axis letterboxes),  so letterboxing will fit width instead (which is what you apparently desired, using that fixed 800 value).  Then upon reading display.actualContentHeight later you’ll find your 1422.2222 fractional height as “proof” that all went according to plan. (and actualContentWidth will be your specified 800.0)

These are good suggesting Dave.  I’ve updated the tutorial to reflect them.  How to fix the 4 zillion config.lua’s out there :slight_smile:

Rob