Hi Lori,
When I work with “letterbox” scale (and I almost always do since it’s my personal preference), I find that setting two variables early on in “main.lua” is extremely valuable for positioning objects that should be “anchored to one side”. These variables are really simple calculations, honestly, and they will be dynamically calculated no matter what screen or device you’re testing on (assuming it’s “letterbox” scale setting).
Basically, they tell you the width and height of the letterbox bars (empty space) on any device:
[lua]
local letterboxWidth = (display.actualContentWidth-display.contentWidth)/2
local letterboxHeight = (display.actualContentHeight-display.contentHeight)/2
[/lua]
Using these, you can simply add or subtract the value from the position of any object which needs to be pushed up against one side of the screen. For the left, you’d subtract “letterboxWidth”, or for the right side, add “letterboxWidth”. Same concept with “letterboxHeight” and the top/bottom of the screen.
If you need to use these in multiple scenes of a Composer-based app, I suggest that you set them to Composer variables that will be known throughout the app, using the “.setVariable()” and “.getVariable()” APIs:
https://docs.coronalabs.com/api/library/composer/setVariable.html
https://docs.coronalabs.com/api/library/composer/getVariable.html
Hope this helps,
Brent
