dynamic spritesheet resolution

Spriteloq does a great job converting my flash to spritesheet, but i was wondering if there was any tips for hi res management.

I mean when I load an image with corona, I just have to do :
local background = display.newImageRect( "background.png", 320, 480 )
And corona makes two things :
1. it loads a 320*480 image, choosing low res image if available, but it's ok if there's only a hi res 640*960 file
2. 320*480 will cover the full screen, whatever iphone.

With spriteloq, I have no idea to do the same : If my spritesheet contain 320*480 image, it will not cover the iphone4 simulator screen.

I hope you will understand what I mean.

hi Antheor,

Thanks for using Spriteloq. Unfortunately Spriteloq doesn't have any support for dynamic spritesheets at the moment, but it's definitely on the roadmap.

In the meantime here's a general outline.

First you'll need to export properly sized swfs at whatever multiple you want to support. In Flash you can take your symbols and stick them inside other symbols and resize then for export. Kind of a hack, but it gets the job done.

Create a spritesheet from those new swfs with some extension to match the sizing, for example, sheet@2.png.

Then in the Corona app, you'll have to check for the display size and then load the appropriate sheet for that size into a SpriteFactory.

Thx for your answer. Glad to hear it's on the roadmap.

Just wanted to add that I don't really miss the hirez autoswitch.

The real thing is the ability to determine the spritesheet size, as in display.newImageRect. (maybe yhis feature could come easier and quicker :)

You mean like have a way to specify what the suffixes mean like this http://developer.anscamobile.com/content/configuring-projects#Dynamic_Image_Resolution

and have the SpriteFactory autodetect?

I can look into this over the weekend. What do you think about passing in the suffix table to the SpriteFactory on creation? I wonder if I can require the config.lua file where this is stored an have the loq_sprite module automatically pick it up. If I can do that, it should be quick to add.

Actually I'd like the feature
local sprite= nfactory:newSpriteGroup(width, heigth)

...So that my sprite takes the same place on the screen whatever the iphone.

BUT ! I checked my config.lua and realized it was :

        content =
                --width = 320,
                --height = 480,
                --scale = "zoomEven"

Hi Don,

I am facing a similar issue where I need to enable dynamic resolution for sprites done in Spriteloq, is there now way to do so? We did higher res. sprites for iPhone 4 and other devices, and they do not display as intended.

Hi lloyd5,

I was just playing around with this this morning to get a better understanding of how dynamic resolution works and how to integrate it with Spriteloq's API.

The key is using display.contentScaleX and display.contentScaleY to determine the correct spritesheet to load.

Then scaling the resulting sprite by that value. For example:

-- Assuming the normal dimensions width = 320, height = 480
-- determines the proper suffix taken from the CrawlSpaceLib
scale, suffix = display.contentScaleX, ""
if scale < 1 then
   if scale > .5 then
       suffix = "@1.5x"
       suffix = "@2x"
local sf = require('loq_sprite').newFactory('sheet' .. suffix)
local sg = sf:newSpriteGroup('mysprite')
sg.curSprite.xScale = display.contentScaleX
sg.curSprite.yScale = display.contentScaleY

Hi Don,

Thanks for this, I'll experiment with this code in the meantime.

Maybe you could do something more like corona, with "newImage" :
direct solution :
myImage = display.newImage( "image.png" )
dynamic solution :
myDynamicImage = display.newImageRect( "baseImage.png", 100, 100 )

With spriteloq, it could be
direct(actual solution) :
local nfactory = loqsprite.newFactory('ninja')
local ninja = nfactory:newSpriteGroup("ninja run")
dynamic solution :
local nfactory = loqsprite.newFactory('ninja')
local ninja = nfactory:newSpriteGroupRect("ninja run",100,100)

I don't know ...

views:821 update:2011/10/12 9:17:43
corona forums © 2003-2011