[SOLVED] Enumerating spritesheet data?

Hello all!

This isn’t necessarily a ‘TexturePacker only’ question, but here goes. TexturePacker outputs nice, neat SpriteSheet data:

local SpriteSheet = {}  
SpriteSheet.getSpriteSheetData = function ()  
 return {  
 frames = {  
 {  
 name = "goblinarcher1.png",  
 spriteColorRect = { x = 0, y = 0, width = 72, height = 68 },  
 textureRect = { x = 363, y = 1254, width = 72, height = 68 },  
 spriteSourceSize = { width = 72, height = 68 },  
 spriteTrimmed = false,  
 textureRotated = false  
 },  
 {  
 name = "goblinarcher2.png",  
 spriteColorRect = { x = 0, y = 0, width = 62, height = 75 },  
 textureRect = { x = 749, y = 1209, width = 62, height = 75 },  
 spriteSourceSize = { width = 62, height = 75 },  
 spriteTrimmed = false,  
 textureRotated = false  
 },  
 {  
 name = "goblinarcher3.png",  
 spriteColorRect = { x = 0, y = 0, width = 65, height = 66 },  
 textureRect = { x = 505, y = 1445, width = 65, height = 66 },  
 spriteSourceSize = { width = 65, height = 66 },  
 spriteTrimmed = false,  
 textureRotated = false  
 },  
  

is there a way I can enumerate through the above spritesheet data? I’d love to get a table with the ‘name’ variables and a matching frame# (that I could just add manually to a counter. Am I making sense? I just wanna avoid parsing the XML data to get what I want if I can help it.

End result I’d like to create a table with the data from the spritesheet like so:

1,goblinarcher1.png
2,goblinarcher2.png
3,goblinarcher3.png

etc. etc.

Appreciate any pointers!

Best,
Mario

[SOLVED!]

OK, where you get your spritesheet setup:

require ("sprite")  
local sheetData = require "coronaTest"  
local data = sheetData.getSpriteSheetData()  
local spriteSheet = sprite.newSpriteSheetFromData( "coronaTest.png", data )  
local spriteSet1 = sprite.newSpriteSet(spriteSheet, 1, 1)  

you just use the ‘data’ variable like so:

 for i=1,#data.frames do  
 print(i..","..data.frames[i].name)  
 end  

and do whatever you want from there.

Perfect!
[import]uid: 11636 topic_id: 18897 reply_id: 318897[/import]