2014年4月11日 星期五

corona-自動調整比例

  local gameBackground =  display.newImageRect("background.png",480,320);

gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY
This feature is only supported by images displayed using display.newImageRect() or by sprites and images taken from image sheets that contain the overall sheet size parameters.
config
    width = 640,
    height = 960, 
iphone 5
實際圖
640*1136
設定為
640*960
上下還是有黑邊,會將照片自動縮放,螢幕顯示一樣為640*960,多出的176高度,依比例顯示在螢幕。
  local gameBackground =  display.newImageRect("bg3.png",640,960);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

iphone 5
實際圖
640*960
設定為
640*960
上下還是有黑邊,螢幕顯示一樣為640*960。
  local gameBackground =  display.newImageRect("bg2.png",640,960);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY


iphone 5
實際圖
640*960
設定為
640*1136
上下無黑邊,螢幕顯示為640*1136,剛好填滿螢幕。

  local gameBackground =  display.newImageRect("bg2.png",640,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY


iphone 5
實際圖
640*1136
設定為
640*1136
上下無黑邊,螢幕顯示為640*1136,剛好填滿螢幕。

  local gameBackground =  display.newImageRect("bg3.png",640,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

小結論
圖片顯示依設定有關,
iphone 5 ok
但iphone 4
圖片上下約176/2=88不會顯示
圖片上下不能有圖案

config
    width = 640,
    height = 1136, 
****最佳iphone 5
實際圖
640*1136
圖片設定為
640*1136
全部ok
  local gameBackground =  display.newImageRect("bg3.png",640,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

iphone 5
實際圖
640*1136
設定為
640*960
全部上下還是有黑邊,螢幕顯示一樣為640*960。XXX
  local gameBackground =  display.newImageRect("bg2.png",640,960);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

iphone 5
實際圖
640*960
設定為
640*960
全部上下還是有黑邊,螢幕顯示一樣為640*960。XXX
  local gameBackground =  display.newImageRect("bg2.png",640,960);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

config
    width = 720,
    height = 1136, 
iphone 5
實際圖
640*1136
設定為
640*1136
上下或旁邊有黑邊。
  local gameBackground =  display.newImageRect("bg3.png",640,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY

iphone 5
實際圖
640*1136
設定為
720*1136
上下或旁邊有黑邊。
  local gameBackground =  display.newImageRect("bg3.png",720,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY
 上下有黑邊。

iphone 5
實際圖
720*1136
設定為
720*1136
上下或旁邊有黑邊。
  local gameBackground =  display.newImageRect("bg3.png",720,1136);
gameBackground.x = display.contentCenterX
gameBackground.y = display.contentCenterY


Several display properties are exposed within Corona to help you work with scaled content. Please refer to the API Reference for a complete list of properties.
  • display.contentWidth and display.contentHeight — read-only properties representing the original width and height of the content, in pixels.
  • display.pixelWidth and display.pixelHeight — entire screen width and height, in pixels.
  • display.viewableContentWidth and display.viewableContentHeight — read-only properties representing the viewable width and height. This is useful if you're using zoomEven scaling, as it will reveal the viewable (uncropped) measurements, in pixels.
  • display.contentCenterX and display.contentCenterY — read-only properties representing the center of the content area, useful for positioning objects along either central axis.
application = 
{
    content = 
    { 
        width = 800,
        height = 1200,
        scale = "letterbox",
     

        imageSuffix =
        {
            ["@2x"] = 1.5
            --high-resolution devices (Retina iPad, Kindle Fire HD 9", Nexus 10, etc.) will use @2x-suffixed images
            --devices less than 1200 pixels in width (iPhone4, iPad2, Kindle Fire 7", etc.) will use non-suffixed images
        }
    }
}

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。