我是电晕的新手,希望背面图像适合所有跨设备。请建议我图像的大小和比例
问问题
5970 次
2 回答
2
你需要三个版本的背景图片
- 320x480
- 720x1140
- 1440x2280
然后,使用下面的 config.lua(它的终极配置 lua)来支持所有可能的设备
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
然后在您的任何lua文件中读取您的背景图像,如下所示
local bgImage = display.newImageRect("textures/title/bg.png", 360, 570)
于 2013-10-03T10:29:48.403 回答
1
根据有关此主题的 Corona 文章,您需要的尺寸与 Arun 的回答所指示的尺寸不同。
这是一个很好的参考链接
基本上,您需要使用该链接上推荐的“魔术尺寸”。
所以这是 380 x 570。在 Arun 的回答中(所有方面,只是想清楚一点)据说是 320 x 480。
在具有视网膜和诸如此类的设备的最新趋势中,我们还需要强烈考虑使用 Corona“Ulimate Config”文件,该文件可在此处获得: 下载 Corona Ultimate Config File
(有关更多详细信息,您可以阅读链接到该文件的这篇文章。)
这将适用于许多不同的设备。
在这个现代时代,外卖是创建一个文件和两个后缀为“@2x”和“@4x”的“更大”文件
- 常规 - 380 x 570(宽 x 高)
- @2x - 760 x 1140
- @4x - 1520 x 2280
然后您可以将其居中(取自第三个链接的代码),如下所示:
background = display.newImage( "background.png", true )
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
于 2014-11-24T09:11:11.353 回答