Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active May 7, 2016 04:24
Show Gist options
  • Save rutcreate/3a3a09d98f00665d3272 to your computer and use it in GitHub Desktop.
Save rutcreate/3a3a09d98f00665d3272 to your computer and use it in GitHub Desktop.
[Corona SDK] Support all screens resolution.
application =
{
content =
{
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["-2x"] = 1.5,
["-4x"] = 3.0,
},
},
}
local modelName = system.getInfo( "model" )
local ratio = display.pixelHeight / display.pixelWidth
----------------------------------------------------------------------
-- iOS devices
----------------------------------------------------------------------
if string.sub( modelName, 1, 2 ) == "iP" then
-- iPad
if string.sub( modelName, 1, 4 ) == "iPad" then
application.content.width = 360
application.content.height = 480
-- iPhone
else
application.content.width = 320
-- iPhone 5
if display.pixelHeight > 960 then
application.content.height = 568
else
application.content.height = 480
end
end
----------------------------------------------------------------------
-- Android devices
----------------------------------------------------------------------
else
if display.pixelWidth >= 600 then
application.content.width = 360
else
application.content.width = 320
end
application.content.height = application.content.width * ratio
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment