Texture Packer or Zwoptex usage

Please tell me there’s a way to do this…I have a hard time believing it’s not possible.

  1. I have a texture generated from Texture Packer. I want to load the texture and instantiate individual pieces…NOT animations…from the texture. Textures are perfectly valid places to put non-animated assets…please don’t tell me I have to create a bunch of 1-frame animations in order to make full use of textures.

  2. IF…and I mean IF…I do have to do that, tell me that newSpriteSet (or a variation of it) has a way to reference frames by name rather than index. Otherwise, how do people manage/update their textures without thoroughly screwing up their frame references??

I have seen NO examples of anyone using packed textures for anything other than animations, and in such cases they’re always pretty trivial.

Thanks in advance for any advice!

-John [import]uid: 29170 topic_id: 19605 reply_id: 319605[/import]

Hi jobahed,

I can’t speak to 1 or 2 with regards to Texture Packer and Zwoptex, but I’m the creator of Spriteloq and I use spritesheets to access 1 frame sprites.

I’ve wrapped the Corona API to make it easy to access any animation by name. So what you want to accomplish is possible, but you’ll probably have to talk with TP’s author or create your own wrappers.

If you use Flash for your art check out Spriteloq. If not, you still might find some value in checking out the Spriteloq API library (loq_sprite.lua) to see how I’m wrapping the Corona API, but it is tightly integrated with the output from Spriteloq. [import]uid: 27183 topic_id: 19605 reply_id: 75729[/import]

Thanks Don, I’ll definitely take a look.

I’d hope that Ansca has an official solution to this…this is pretty basic.

Ultimately, I may have to write my own wrapper, or (ugh) just use individual images for now. Blah! :frowning:

Sorry for the rant!

-John [import]uid: 29170 topic_id: 19605 reply_id: 75808[/import]

If you are just wanting to grab a single image from your sprite sheet you can do it something like this… I’m using Texture Packer.

Set up your sprite sheet for use somewhere in your initialization process

 data = sheetData.getSpriteSheetData()  
 spriteSheet = sprite.newSpriteSheetFromData( "artwork.png", data )  

Here’s a example of a function I have that returns me 1 of 9 random bottle images from my sprite sheet

 function getRandomBottle()  
 local bottleIndex = math.random(1, 9)  
 local spriteSet = sprite.newSpriteSet(spriteSheet,bottleIndex,1)  
 bottle = sprite.newSprite(spriteSet)  
 return bottle  
 end  

You are correct in that you need to manage your indexes if you start changing the names of your image assets OR if you add new images into the mix as TP will arrange them alphabetically in the generated lua file, however it’s not that much additional work to add a function to scan through that table and return you the index by a name search.

Hope that helps,
Croisened
[import]uid: 48203 topic_id: 19605 reply_id: 75823[/import]

Thanks Croisened, that’s what I needed!

-John [import]uid: 29170 topic_id: 19605 reply_id: 75843[/import]