2013-10-03 38 views

回答

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) 
+0

thnks @Arun但是当我设置宽度= 320, height = 480, scale =“zoomEven”,那么后面的图像适合所有设备。 – Arpi

+0

那没关系。但这不是推荐的选择。您必须使用scale =“letterBox”来避免更高分辨率设备中的图像像素问题 – Kenshin

+0

感谢Arun每个图像的三个版本意味着在图像名称末尾使用@ 2x或4x具有相同的名称? – Tony

1

根据关于这一问题的电晕文章,你会想要一个不同大小比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 
+0

感谢您的回答迈克,但是这是与资产后缀(@ 2x等)适用于Android的代码也可以这只适用于苹果设备?谢谢 – Tony

+0

好问题。我只想说iOS。 你可能想看看有什么要收集[从这个链接](http://docs.coronalabs.com/guide/distribution/buildSettings/index。html#launchimage) 这是用于启动画面,并且可能会将您设置在正确的轨道上以确定正确的背景图像大小。 – mikeDOTexe