2013-10-03 39 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