Graphics 电晕中所有设备的背景图像大小

Graphics 电晕中所有设备的背景图像大小,graphics,coronasdk,screen-resolution,Graphics,Coronasdk,Screen Resolution,我是科罗纳的新手,希望背面的图像适合所有的交叉设备。 请告诉我图像的大小和比例您需要三种版本的背景图像 320x480 720x1140 1440x2280 然后,使用下面的config.lua(其最终配置lua)支持所有可能的设备 if string.sub(system.getInfo("model"),1,4) == "iPad" then application = { content = {

我是科罗纳的新手,希望背面的图像适合所有的交叉设备。
请告诉我图像的大小和比例

您需要三种版本的背景图像

  • 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)

根据科罗纳关于这个主题的文章,你会想要一个不同于阿伦的答案所指出的尺寸

这是一个好主意

基本上,你会想使用链接上推荐的“魔法大小”

这是380 x 570。在阿伦的回答中(从各方面来说,只是想澄清一下),据说是320 x 480

<>在最近的视网膜和WHOT的设备趋势中,我们还需要考虑使用科罗娜啤酒“ULIMATE CONFIG”文件,这是在这里可以得到的:

(有关更多详细信息,请阅读。)

这将适用于许多不同的设备

在这个现代时代,外卖是创建一个文件和两个后缀为“@2x”和“@4x”的“较大”文件

  • 常规-380 x 570(宽x高)
  • @2x-760x1140
  • @4x-1520 x 2280
然后可以将其居中(代码取自第三个链接),如下所示:


thnks@Arun,但当我设置宽度=320,高度=480,scale=“zoomEven”时,返回图像适用于所有设备。这没关系。但这不是一个建议的选择。您必须使用scale=“letterBox”以避免高分辨率设备中的图像像素关联问题感谢Arun每个图像的三个版本意味着图像名称末尾有@2x或4x的相同名称?感谢mike的回答,但这段带有资产后缀(@2x等)的代码是否也适用于android,还是仅适用于apple设备?谢谢你的提问。我想说的只是iOS。您可能希望看到为启动屏幕收集的内容,并且可以为您确定正确的背景图像大小设置正确的轨道。
background = display.newImage( "background.png", true )
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2