Reputation: 407
I am newbie in corona and want that back image should fit for all cross devices . please suggest me what should be size of my image and scale
Upvotes: 2
Views: 6039
Reputation: 487
According to the Corona article on this subject, you'll want a different size than indicated by Arun's answer.
Here's a good link to reference
Basically, you'll want to use the "magic size" recomended on that link.
So that's 380 x 570. In Arun's answer (all respect, just trying to be clear) it was said to be 320 x 480.
In the recent trend of devices having retina and whatnot, we also need to strongly consider using the Corona "Ulimate Config" file, which is available here: Download for Corona Ultimate Config File
(For more details, you can read this post that links to that file.)
That will work for a lot of the diverse devices.
The takeaway, in this modern era, is to create a file and two "larger" files with the suffix of "@2x" and "@4x"
then you can center it (code taken from third link) as such:
background = display.newImage( "background.png", true )
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
Upvotes: 1
Reputation: 1030
You need three versions of background images
Then, use the below config.lua ( its ultimate config lua ) to support all possible devices
if string.sub(system.getInfo("model"),1,4) == "iPad" then
application =
{
content =
{
fps = 60,
width = 360,
height = 480,
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
notification =
{
iphone = {
types = {
"badge", "sound", "alert"
}
},
google =
{
projectNumber = "xxxx",
},
}
}
elseif string.sub(system.getInfo("model"),1,2) == "iP" and display.pixelHeight > 960 then
application =
{
content =
{
antialias = true,
fps = 60,
width = 320,
height = 568,
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0
},
},
notification =
{
iphone = {
types = {
"badge", "sound", "alert"
}
},
google =
{
projectNumber = "xxxx",
},
}
}
elseif string.sub(system.getInfo("model"),1,2) == "iP" then
application =
{
content =
{
antialias = true,
fps = 60,
width = 320,
height = 480,
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
notification =
{
iphone = {
types = {
"badge", "sound", "alert"
}
},
google =
{
projectNumber = "xxxx",
},
}
}
elseif display.pixelHeight / display.pixelWidth > 1.72 then
application =
{
content =
{
antialias = true,
fps = 60,
width = 320,
height = 570,
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}
else
application =
{
content =
{
antialias = true,
fps = 60,
width = 320,
height = 512,
scale = "letterBox",
xAlign = "center",
yAlign = "center",
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
notification =
{
iphone = {
types = {
"badge", "sound", "alert"
}
},
google =
{
projectNumber = "xxxx",
},
}
}
end
Then read your background image in any of your lua file like below
local bgImage = display.newImageRect("textures/title/bg.png", 360, 570)
Upvotes: 2