As part of Corona's scaling capabilities, developers can provide images at multiple resolutions and the program will choose the best one based on device resolution. This is done through the use of display.newImageRect() rather than display.newImage(). I would like to use this feature with spine assets, but my current asset loader does not utilize this feature. Looking through the forums, some users have indicated that they modified the loader (or runtime?) to do so, but did not mention how, so I am asking for advice from anybody who has done so.
My current asset loader:
local sprite = spine.Skeleton.new(skeletonData)
function sprite:createImage(attachment)
return display.newImage(skinPath..attachment.name..'.png')
end
The primary issue I see is that newImageRect requires the image's dimensions as arguments. My thought was to load the asset as a non-dynamic temporary display object first, then use the dimensions from that image to create the actual asset as a dynamic image. However, this would require each asset to be loaded twice, decreasing performance.
Possible solution:
local sprite = spine.Skeleton.new(skeletonData)
function sprite:createImage(attachment)
local temp = display.newImage(skinPath..attachment.name..'.png')
return display.newImageRect(skinPath..attachment.name..'.png',temp.width,temp.height)
end
Has anybody tried this? Or have a better suggestion?
Also, were there any other changes needed to runtime beside the display function?
Thanks.