Multiple Sprite Sheets

I’m having a problem with multiple sprite sheets. The Error I get is this : Could Not Create Sprite. The Image Sheet has No Frames Defined.

The Fairy Sprite (the first one in the sequence data) works Fine.
 
Here is my Code:

local sheetData = { width=92, height=92, numFrames=24 } local imageSheet = graphics.newImageSheet("PIXIESPRITESheet.png",sheetData) local sheetData2 = {width=107,height=107, numframes=16} local imageSheet2=graphics.newImageSheet("slotfirespritesheet.png", sheetData2) local sequenceData = { { name="flyer",sheet=imageSheet, frames={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,87,6,5,4,3,2,1},start=1, count =24, time=500}, {name="slotfire", sheet=imageSheet2, frames={2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1},start=1, count=16,time=1000} } local fire1 = display.newSprite(imageSheet2, sequenceData) fire1.x=292 fire1.y = 745 fire1.xScale=1 fire1.yScale=1 fire1.name="fire1" fire1:setSequence("slotfire") sceneGroup:insert(fire1) fire1:play() local fairy = display.newSprite(imageSheet, sequenceData) fairy.x=700 fairy.y = 450 fairy.xScale=1 fairy.yScale=1 fairy.name="fairy" fairy:setSequence("flyer") sceneGroup:insert(fairy) fairy:play() fairy:addEventListener("tap",hints)

You have an error where you’re specifying the frames in the first one:
 

,10,9,_ 87 _,6,

You don’t have 87 frames.  I suspect you meant 10, 9, 8, 7, 6…

Rob

Thanks Rob, for catching that. Even though that was wrong it still works. It’s the ‘slotfire’. That’s not working at the moment.

Shouldn’t the sheetData have the sheetContentWidth/sheetContentHeight set for them? Or are these being picked up somewhere else?

Thanks Alex, I will try that right now. Thanks again. I’m hoping this works.

I added the sheetContentWidth and Height and still nothing. I’m also getting the Error index local ‘fire1’ ( a nil value)

Looking a bit more closely at your code, you’re defining both the frame-by-frame animation of the sprite  and the start/count values of the animation, which are mutually exclusive. It should be one set (frames={}, or start=n,count=n+t). 

Now is the time to confirm that those graphics assets are being created correctly. I’d suggest adding some print statements. If you’re getting that error when creating the “fire1” object, that means that the asset being used to create that object doesn’t exist. Can you confirm that that those are the correct names of those assets?

I think you may need to have two sequenceData’s.  I think they way you’re doing it is that it looking for two sequences in one sheet.  Since you have two sheets, you may need two sequenceData’s.

Rob

Alex I tried that to no avail. Yes those are the correct names of the assets. What I can’t understand is why one works perfectly and the other doesn’t. Seeing that the code for the two sprites is almost identical.

Rob, I thought adding sheet=imageSheet1 and the sheet=imageSheet2 in the sequence data would take care of that. I will try having to separate sequencedatas and see where that gets me…

  Hi animationarsenal.

  Your problem is:

local sheetData2 = {width=107,height=107, numframes=16}

  It should be “numFrames”. You can use one sequenceData with more spritesheets without any error.

Khanh.dq you are an Eagle Eye. Thank you, that was the problem. Everything is working now. Thanks to Rob and Alex as well for their help, it is all much appreciated.

You have an error where you’re specifying the frames in the first one:
 

,10,9,_ 87 _,6,

You don’t have 87 frames.  I suspect you meant 10, 9, 8, 7, 6…

Rob

Thanks Rob, for catching that. Even though that was wrong it still works. It’s the ‘slotfire’. That’s not working at the moment.

Shouldn’t the sheetData have the sheetContentWidth/sheetContentHeight set for them? Or are these being picked up somewhere else?

Thanks Alex, I will try that right now. Thanks again. I’m hoping this works.

I added the sheetContentWidth and Height and still nothing. I’m also getting the Error index local ‘fire1’ ( a nil value)

Looking a bit more closely at your code, you’re defining both the frame-by-frame animation of the sprite  and the start/count values of the animation, which are mutually exclusive. It should be one set (frames={}, or start=n,count=n+t). 

Now is the time to confirm that those graphics assets are being created correctly. I’d suggest adding some print statements. If you’re getting that error when creating the “fire1” object, that means that the asset being used to create that object doesn’t exist. Can you confirm that that those are the correct names of those assets?

I think you may need to have two sequenceData’s.  I think they way you’re doing it is that it looking for two sequences in one sheet.  Since you have two sheets, you may need two sequenceData’s.

Rob

Alex I tried that to no avail. Yes those are the correct names of the assets. What I can’t understand is why one works perfectly and the other doesn’t. Seeing that the code for the two sprites is almost identical.

Rob, I thought adding sheet=imageSheet1 and the sheet=imageSheet2 in the sequence data would take care of that. I will try having to separate sequencedatas and see where that gets me…

  Hi animationarsenal.

  Your problem is:

local sheetData2 = {width=107,height=107, numframes=16}

  It should be “numFrames”. You can use one sequenceData with more spritesheets without any error.