【发布时间】:2016-10-30 23:09:51
【问题描述】:
我使用 corona 已经有一段时间了,我想知道如何制作一个精灵(使用纹理打包器)并将其设置为我的应用程序的背景。我还希望它能够适应尽可能多的设备,而不会裁剪出任何精灵内容。简而言之,我希望精灵成为适合整个屏幕的背景,而不会丢失任何精灵的内容
【问题讨论】:
标签: coronasdk sprite-sheet texturepacker
我使用 corona 已经有一段时间了,我想知道如何制作一个精灵(使用纹理打包器)并将其设置为我的应用程序的背景。我还希望它能够适应尽可能多的设备,而不会裁剪出任何精灵内容。简而言之,我希望精灵成为适合整个屏幕的背景,而不会丢失任何精灵的内容
【问题讨论】:
标签: coronasdk sprite-sheet texturepacker
希望对你有帮助:
local _W = display.actualContentWidth
local _H = display.actualContentHeight
local bg = display.newImage( 'bg.jpg' )
bg.x, bg.y = display.contentCenterX, display.contentCenterY
local mode = 'inside'
-- the image will fill the device width/height exactly
if mode == 'stretch' then
bg.width, bg.height = _W, _H
-- the image will be scaled proportionally to fit inside the device width/height
elseif mode == 'inside' then
local scale = math.min( _W / bg.width, _H / bg.height )
bg:scale(scale, scale)
-- the image will be scaled proportionally to completely fill the area,
-- allowing portions of it to exceed the bounds defined by device width/height
elseif mode == 'outside' then
local scale = math.max( _W / bg.width, _H / bg.height )
bg:scale(scale, scale)
end
【讨论】: