Hi Corona Peeps.
I’m a rusty php, mysql website developer who picked up Corona SDK for the first time a weekago.
So I’ve started to build my own point and click adventure game. (I like to jump right in).
I’m trying to position a “next” (right arrow pointing) button for users to click on to move to the next backstory description. The code could also be used for scrolling through an inventory in the future as well.
Here’s the thing.
In my config.lua file i’ve set the enviroment to…
content =
{
width = 320,
height = 480,
scale = “letterbox”,
xAlign = “center”,
yAlign = “center”,
fps = 30,
}
So when I print the results of the various different display width settings, they all say… 480 or bigger if viewing in iPhone X etc.
In order to get my right arrow to sit 10 units in from the right edge of any smart devices I’ve put the following line of code:
local btnRightSettings = {
left = display.viewableContentWidth - 10,
top = display.safeScreenOriginY + 40,
id = “btnNext”,
label = “Next”,
onEvent = handleRightButtonEvent,
defaultFile = “UI/ArrowRIGHT_W500xX500_Default.png”,
overFile = “UI/ArrowRIGHT_W500xX500_OnClick.png”,
width = 40,
height = 40
}
This positions the button perfectly on the following devices.
- HTC Sensation
- Samsung Galaxy S3 & S5
- Amazon TV
- Ouya
- Apple TV
- HTC Windows Phone 8S
- Nokia Lumia 920
- Samsung ATVIS
But with these devices it’s positioned all over the place
- Kindle 7" & 8.9" (the tip of the button is off screen on both these devices.)
- iPhone 4S, iPad Air, Pro, & Mini (half of the button is off screen)
- iPhone 5 (button is positioned to far into the centre of the screen)
- iPhone 6 & 6Plus (positioned to far into the centre of the screen but less then the iPhone 5)
- iPhone X (positioned around 20% to far into the screen)
I’ve not yet tested everything else, but you get the idea.
Is there a method call I should be using instead of display.viewableContentWidth - 10?
Is there a way to write a settings function that identifies the device in use and then runs code relevant to it, to position the button accordingly? (I’m a perfectionist and normally just CSS my way out of these issues in other coding environments).
Is this “life” with Lua and something I just put up with?
Advice and guideance please