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

时间:2013-10-03 07:51:19

标签: graphics corona screen-resolution

我是电晕的新手,并希望背面图像适合所有交叉设备。    请告诉我应该是我的图像大小和比例

2 个答案:

答案 0 :(得分: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)

答案 1 :(得分:1)

根据Corona关于此主题的文章,您需要的尺寸与Arun的回答不同。

这是一个很好的link to reference

基本上,你会想要使用"魔法大小"建议在那个链接上。

这就是380 x 570.在Arun的回答中(尊重,只是想明确),据说是320 x 480。

在最近有视网膜等设备的趋势中,我们还需要强烈考虑使用Corona" Ulimate Config"文件,可在此处获得: Download for Corona Ultimate Config File

(有关详细信息,请参阅this post that links to that 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