Resolution of devices are different.
So we need to set to percent.
I found below project.
https://github.com/hongyangAndroid/android-percent-support-extend
Do you have a plan that display objects set size to percent?
Resolution of devices are different.
So we need to set to percent.
I found below project.
https://github.com/hongyangAndroid/android-percent-support-extend
Do you have a plan that display objects set size to percent?
In Corona, you set the canvas size which is independent of the screen resolution.
So you set it to say 480 x 320 in config.lua (this is what I use), and use this scale when calculating the size of your objects.
HOWEVER - on iPhone 5 upwards, your canvas essentially becomes 568 x 320, so you need to allow for the extra space.
On an iPad, your canvas will be 480 x 360, again you need to allow for the extra space.
On Android, the canvas size is variable, but I handle it all like this:
[lua]
— LANDSCAPE
_G.yO = (display.actualContentHeight - 320) / 2 – space outside 320 pixels on wider devices (iPad, Android tabs)
_G.xO = (display.actualContentWidth - 480) / 4 – space outside 480 on taller devices (iPhone5+)
– OR PORTRAIT
_G.yO = (display.actualContentHeight - 480) / 4 – space outside 480 pixels on taller devices
_G.xO = (display.actualContentWidth - 320) / 2 – space outside 320 on wider devices
[/lua]
If I want to place a bar at the top of the screen, on any device (portrait):
[lua]
local i = display.newRect(0, 0, display.actualContentHeight, 50)
i.anchorY = 0 – set reference point to topCenter
i.x = 160
i.y = 0 - yO*2 – position the bar at the top of the screen, no matter what the device
[/lua]
If you want to use percentages, you could store the effective canvas size (i.e. 480 x 320, 568 x 320, 480 x 360), from display.actualContentHeight and display.actualContentWidth and then size your images as a percentage of these values.
Where do you place this _G.y0 = … code?
In Corona, you set the canvas size which is independent of the screen resolution.
So you set it to say 480 x 320 in config.lua (this is what I use), and use this scale when calculating the size of your objects.
HOWEVER - on iPhone 5 upwards, your canvas essentially becomes 568 x 320, so you need to allow for the extra space.
On an iPad, your canvas will be 480 x 360, again you need to allow for the extra space.
On Android, the canvas size is variable, but I handle it all like this:
[lua]
— LANDSCAPE
_G.yO = (display.actualContentHeight - 320) / 2 – space outside 320 pixels on wider devices (iPad, Android tabs)
_G.xO = (display.actualContentWidth - 480) / 4 – space outside 480 on taller devices (iPhone5+)
– OR PORTRAIT
_G.yO = (display.actualContentHeight - 480) / 4 – space outside 480 pixels on taller devices
_G.xO = (display.actualContentWidth - 320) / 2 – space outside 320 on wider devices
[/lua]
If I want to place a bar at the top of the screen, on any device (portrait):
[lua]
local i = display.newRect(0, 0, display.actualContentHeight, 50)
i.anchorY = 0 – set reference point to topCenter
i.x = 160
i.y = 0 - yO*2 – position the bar at the top of the screen, no matter what the device
[/lua]
If you want to use percentages, you could store the effective canvas size (i.e. 480 x 320, 568 x 320, 480 x 360), from display.actualContentHeight and display.actualContentWidth and then size your images as a percentage of these values.
Where do you place this _G.y0 = … code?