Spritesheets for multiple characters/sprites

From what I can understand from documentation, all sprites in a Spritesheet must have the same x*y dimensions. Is that restriction still true?

I am working on a game that has dozens of non-animated sprites of significantly different dimensions. How can I use Corona Spritesheets to minimize texture memory allocation?

Example [import]uid: 7356 topic_id: 2636 reply_id: 302636[/import]

According to the release notes of the latest GE, the restriction is gone. The procedure to use this new feature should be explained in the new documentation which I had no access to yesterday. Maybe it is accessable today, i don’t know. [import]uid: 5712 topic_id: 2636 reply_id: 7564[/import]

YES! It is now supported… :slight_smile:

Congrats to Ansca devs

http://developer.anscamobile.com/content/game-edition-sprite-sheets [import]uid: 7356 topic_id: 2636 reply_id: 7570[/import]

The time to start working with spritesheets has come for me and I have a hard time mastering them.
I am using TexturePacker, but I guess it’s the same with Zwoptex.

According to the documentation you have to follow these steps for setting up an animation of “mysprite” that has 8 frames:

[lua]require “sprite”
local mysprite = sprite.newSpriteSheetFromData( “out.png”, require(“out”).getSpriteSheetData() )
local spriteSet = sprite.newSpriteSet(mysprite,1,8)
sprite.add(spriteSet,“myAnimation1”,1,8,1000,0)
local spriteInstance = sprite.newSprite(spriteSet)
spriteInstance:setReferencePoint(display.BottomRightReferencePoint)
spriteInstance.x = 200
spriteInstance.y = 200
spriteInstance:prepare(“myAnimation1”)
spriteInstance:play()[/lua]

However, I am not interested on animations at all. I would like to give Corona a SpriteSheet from TexturePacker that includes several 1-frame character sprites and call them by name. TexturePacker reads the image files that I have in my assets folder and keep this information in the spritesheet.lua file for Corona.

So, using spritesheets, how would I setup and display a single-framed sprite that has been stored to image “seeker.png” and is included to “out.png” spritesheet that TexturePacker makes? Isn’t there a way to retrieve the sprite by image name from the container spritesheet?
… I have managed to display the sprite using:
[lua]require “sprite”
local mysprite = sprite.newSpriteSheetFromData( “out.png”, require(“out”).getSpriteSheetData() )
local spriteSet = sprite.newSpriteSet(mysprite,4,1) --desired sprite has is indexed 4th in out.lua
local spriteInstance = sprite.newSprite(spriteSet)
spriteInstance:setReferencePoint(display.BottomRightReferencePoint)
spriteInstance.x = 200
spriteInstance.y = 200[/lua]

…but I suspect there is a shorter way to do this and by using image names instead of arithmetic indexes. Isn’t there?
From documentation :
“In either case, creating a new sprite sheet object does not actually result in anything being added to the display list. To do that you need to create a sprite (and optionally sprite sets) from your sprite sheet object.”

EDIT: I found a solution to get sprites by image names. So the question is whether a spriteSet is indeed necessary or not, for a single-framed sprite. [import]uid: 7356 topic_id: 2636 reply_id: 8985[/import]

What was this solution? I have been toying in my head with the idea of using a table to store the names?

Thanks for the info! [import]uid: 9968 topic_id: 2636 reply_id: 9000[/import]

yeah what did you do? [import]uid: 5354 topic_id: 2636 reply_id: 9021[/import]

Good news!

I am currently giving the final touches to a “SpriteGrabber” class, which will conveniently extract sprites by image name from a named spritesheet. I am going to share it, as soon as possible, here and also submit it to the code exchange section with usage examples. [import]uid: 7356 topic_id: 2636 reply_id: 9056[/import]

I forgot to announce SpriteGrabber here, as promised. It is now in code section.
I’m currently using it for my first game with Corona and find it a life-saver. Enjoy!

Also started a SpriteGrabber thread for suggestions, feedback, problems etc… [import]uid: 7356 topic_id: 2636 reply_id: 9508[/import]