我是日冕中的新手,并希望后面的图像应适合所有跨设备。 请建议我应该是什么我的图像的大小和规模在日冕中的所有设备的背景图像大小
回答
你需要背景图像的三个版本
- 小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)
根据关于这一问题的电晕文章,你会想要一个不同大小比Arun的答复中指出。
这里有一个很好的link to reference
基本上,你要使用“魔尺寸” recomended该链接。
所以这是380 X 570在阿伦的回答(所有的尊重,只是想清楚),有人说是320 x 480
在近期有视网膜和诸如此类设备的发展趋势,我们还需要强烈考虑使用电晕“Ulimate配置”文件,该文件是可在这里: Download for Corona Ultimate Config File
(有关详细信息,你可以阅读this post that links to that file。)
将为很多不同的设备上工作。
外卖,在这个现代化的时代,是创建一个文件和两个“大”的文件与“@ 2X”和“@ 4倍”
- 普通的后缀 - 380 X 570(宽x高度)
- @ 2x - 时760 X 1140
- @ 4倍 - 1520 X 2280
那么你可以居中(从第三个环节采取代码)这样:
background = display.newImage("background.png", true)
background.x = display.contentWidth/2
background.y = display.contentHeight/2
感谢您的回答迈克,但是这是与资产后缀(@ 2x等)适用于Android的代码也可以这只适用于苹果设备?谢谢 – Tony
好问题。我只想说iOS。 你可能想看看有什么要收集[从这个链接](http://docs.coronalabs.com/guide/distribution/buildSettings/index。html#launchimage) 这是用于启动画面,并且可能会将您设置在正确的轨道上以确定正确的背景图像大小。 – mikeDOTexe
- 1. Android:支持所有设备的背景图像大小(以像素为单位)
- 2. 在日冕里的大图像旋转
- 3. 在android中的背景图像大小
- 4. 适合所有iOS设备的背景大小
- 5. 移动设备上的背景图像大小
- 6. 移动设备的背景图像大小
- 7. 背景大小:封面不设置背景图像的高度
- 8. 背景图像大小iphone
- 9. body.class背景图像大小
- 10. Android:背景图像大小
- 11. 锁背景图像大小
- 12. 所有设备的复杂背景图像定位
- 13. 自动布局背景图像在所有设备上工作
- 14. 从启动图像中获取所有设备屏幕的iOS背景图像
- 15. 如何在jquery中设置动画的背景图像大小
- 16. 问题在设备装载大的背景图像(Andengine)
- 17. 背景大小与css sprite图像中的背景位置
- 18. 在日冕中压缩位图图像
- 19. 图像大小相同的UITableview单元上的所有设备
- 20. 背景图像的大小调整
- 21. 大小的DIV背景图像
- 22. 可调整大小的背景图像
- 23. ActionBarSherlock背景的图像大小
- 24. 全页大小的背景图像
- 25. Android的背景图像大小
- 26. Chrome动画GIF背景图像没有播放 - 背景大小
- 27. 设置背景中精灵图像位置的大小
- 28. (CSS)移动设备的背景图像调整大小的问题
- 29. 移动设备上的背景图像太小。怎么修?
- 30. 缩放大CSS背景图像的移动设备
thnks @Arun但是当我设置宽度= 320, height = 480, scale =“zoomEven”,那么后面的图像适合所有设备。 – Arpi
那没关系。但这不是推荐的选择。您必须使用scale =“letterBox”来避免更高分辨率设备中的图像像素问题 – Kenshin
感谢Arun每个图像的三个版本意味着在图像名称末尾使用@ 2x或4x具有相同的名称? – Tony