Dynamic SpriteSheet Resolution

Currently the lack of dynamic spritesheet resolution support is holding back Lime users (as well as anyone else that uses spritesheets) from fully taking advantage of cross-platform development.

[import]uid: 5833 topic_id: 6039 reply_id: 306039[/import]

@GrahamRanson

Could you describe what exactly do you mean by saying “dynamic spritesheet resolution” ? What would ideally like to happen?

I have done some work in an unreleased version of SpriteGrabber that could potentially help. [import]uid: 7356 topic_id: 6039 reply_id: 20673[/import]

What I would like is that instead of doing something like newSpriteSheet I could call newSpriteSheetRect like you can with newImageRect in order to allow for different spritesheets depending on the resolution. [import]uid: 5833 topic_id: 6039 reply_id: 20675[/import]

I do this inside SpriteGrabber by checking the provided versions for a spritesheet (sd,hd etc) and selecting the one which best fits to the device’s resolution. It is absolutely doable by combining detection and scaling.

I had decided to keep this feature out of SpriteGrabber releases as dynamic content scaling is not the exact interest of the module. Maybe I should think that again.

The only problem currently is an SDK bug that distorts the position of sprites if their frames are not of fixed dimensions and they are scaled. I want to keep non-fixed dimensions so I always provide all the required asset versions for the devices I support to prevent the need for scaling (thus I avoid to encounter the aforementioned bug). However if you want to support Android devices you cant know the exact dimensions so there is an urgent need for Ansca to resolve this bug. [import]uid: 7356 topic_id: 6039 reply_id: 20684[/import]

I was thinking of doing something like that however I wasn’t sure if you could get the resolution of the device if someone has put width/height in config.lua for scaling? [import]uid: 5833 topic_id: 6039 reply_id: 20949[/import]

Yes, you can’t get resolution if you set a reference dimensions set inside config.lua

I opted for my own solution (that stops Adaptive Content Scaling from working). Specifically, I have two blocks of code in my config.lua so that I can activate/deactivate either solution (mine/Ansca).

Also, I have my code to support both solutions and depending of the maturity of each one I am going to select whichever gives the most advantages when publishing my game. Currently, Ansca’s solution is very convenient for same-ratio devices but not very good for universal scaling. [import]uid: 7356 topic_id: 6039 reply_id: 20957[/import]

Thanks for the info, I will put some thought into my own solution like you have done until Ansca put in a solution themselves. [import]uid: 5833 topic_id: 6039 reply_id: 20958[/import]

http://developer.anscamobile.com/forum/2010/12/08/dynamic-retina-spritesheets-heres-how [import]uid: 12108 topic_id: 6039 reply_id: 20959[/import]

Oh, I didn’t know about the contentScaleX property, certainly looks promising. Thank you! [import]uid: 5833 topic_id: 6039 reply_id: 20964[/import]

Here is the whole story on content scaling with spritesheets (posts 64 - 89).
Also, here is some info on my approach. [import]uid: 7356 topic_id: 6039 reply_id: 20966[/import]

I agree with you that layouts using percent are really the only way to go for universal builds. [import]uid: 5833 topic_id: 6039 reply_id: 21035[/import]

I posted a temporary solution for this bug here:

http://developer.anscamobile.com/forum/2010/12/08/dynamic-retina-spritesheets-heres-how#comment-33087 [import]uid: 46260 topic_id: 6039 reply_id: 33093[/import]

Yes, you can’t get resolution if you set a reference dimensions set inside config.lua

[blockcode]
function getDisplayHeight()
return roundNumber (
display.viewableContentHeight / display.contentScaleY, 2 )
end

function getDisplayWidth()
return roundNumber (
display.viewableContentWidth / display.contentScaleX, 2 )
end

– Thanks to http://lua-users.org/wiki/SimpleRound
function roundNumber( num, idp )
local mult = 10^( idp or 0 )
return math.floor( num * mult + 0.5 ) / mult
end
[/blockcode] [import]uid: 71767 topic_id: 6039 reply_id: 72046[/import]