I would recommend reading this before getting into much of an in-depth discussion about how to set your config.lua:
https://coronalabs.com/blog/2018/08/08/understanding-content-scaling-in-corona/
Now to the original question. There is a lot of good things to learn from Corona Cannon. It’s a pretty solid template. However, that config.lua was developed for a purpose of making sure that the top, left corner of the device was 0, 0 and the bottom, right was display.contentHeight, display.contentWidth.
This makes edge positioning easier. People really didn’t want to write complex positioning equations using the longer display.actualContentWidth and display.screenOriginX (and the Height, Y companions). Lets face it, if you want to put a button at the bottom right of the screen:
local button = display.newCircle( display.contentWidth - 25, display.contentHeight - 25, 25 )
is a heck of a lot easier to write than:
local button = display.newCircle( display.actualContentWidth - 25 + display.screenOriginX, display.actualContentHeight - 25 + display.screenOriginY, 25 )
But in doing this, you actually make designing your game a lot harder on yourself. Edge positioned items are generally done once. You’re only going to position that button, high score, # of lives left, etc. once. You’re only going to have a small number of items to position around the edges. As we like to say in our house “Pick your battles”. Is it worth it to make positioning 5-6 objects around the edges easier if it means more work to position the rest of the game elements? In many cases, the answer to that question is a resounding “No”.
For card games where you will spread your card stacks out over the full width of the screen or games like Pop-a-Lock where pretty much everything is centered, then a computed config.lua can save you some time. But for other games, like Angry Birds, you’re probably going to create more problems than you are solving.
Lets take a deeper look into Angry Birds (i.e. Corona Cannon in this case). An iPhone X is really wide (since it’s a landscape game) and a narrow height. But you might want to play the same game on an iPad which is a fairly square device. If you position your slingshot 700 points away from the pig’s tower on the phone but on the iPad, they are only 400 pixels apart then the game will play differently on the different devices.
In this case a fixed config.lua with a centered content area where you build the game within your defined width and height will make building a game that plays the same across devices easier. It makes positioning gameplay elements easier. You know 0, 0 will be on screen. You know any objects placed at display.contentWidth/Height will be on screen.
To build game like Angry Birds with a computed config.lua you end up having to do this:
local slingShot = display.newImageRect(...) slingShot.x = display.contentCenterX - 300 local pigTower = display.newGroup() pigTower.x = display.contentCenterX + 300
when dealing with all of your game elements is a lot more work than:
local slingShot = display.newImageRect(...) slingShot.x = 100 local pigTower = display.newGroup() pigTower.x = 700
Now you still have to build a background that fits the full width and height of the screen which means using edge calculations but when dealing with dozens of game elements vs. a few UI elements, a fixed config.lua saves you more work in more conditions than a computed config.lua does.
You have to think about your game and what’s best for you. I’m currently working on a side-scrolling space shooter and I have chosen to go with a fixed config.lua for it because I need the player’s ship to be the same distance away from the enemies.
Rob