Sprites not Working!

Hi everyone,

I am having a very strange issue: 

I have created using zwoptex first, and texture packer a 2 frames sprite image.  But the problem is that every time I try to implement the spritesheet I get an error:

bad argument #2 to 'newImageSheet' (for single frame size, 'options' table must contain valid 'width' and 'height' values)

and here’s my code implementation:

 local catSheetData = { width =139, height =122, numFrames=2, sheetContentWidth=128, sheetContentHeight=256 } local catImageSheet = graphics.newImageSheet("cat\_running.png", options) local sequenceCatData = { {name="catRun", start=1, count=2, time=750} } local runcat = display.newSprite(catImageSheet, sequenceCatData) runcat.x = \_W\*0.5 - 190 runcat.y = \_H\*0.5 + 100 runcat:scale(0.3, 0.3) runcat:setSequence("catRun") runcat:play()

and I have included the attached spritesheet png file I am using.   I have tried using other different sprites from tutorials and it all works fine, but when I try to use my own sprite that I created using zwoptex and Texture packer I get the above error.

Anyone knows what’s going on? What am I doing wrong?

Any help is highly appreciated.

Thanks

Line 3 shouldn’t be :

local catImageSheet = graphics.newImageSheet("cat\_running.png", catSheetData)

?

catSheetData, instead of options.

Hi fkakos, you are right. It was my typo when I was entering the cos here. In my real code file I have it using catSheetData and still having a the same issue.

Hi @magadistudio,

I see in your sheet setup, you have a width of 139, but the overall sheet is only 128. This might be the issue.

Brent

Hi @Brent,

Thanks for the response! It works! Oh my goodness, I can’t believe I made that mistake :frowning: That makes perfect sense.  

Thank you very much!

Line 3 shouldn’t be :

local catImageSheet = graphics.newImageSheet("cat\_running.png", catSheetData)

?

catSheetData, instead of options.

Hi fkakos, you are right. It was my typo when I was entering the cos here. In my real code file I have it using catSheetData and still having a the same issue.

Hi @magadistudio,

I see in your sheet setup, you have a width of 139, but the overall sheet is only 128. This might be the issue.

Brent

Hi @Brent,

Thanks for the response! It works! Oh my goodness, I can’t believe I made that mistake :frowning: That makes perfect sense.  

Thank you very much!

This is code correct

–================================================================================================

local catSheetData = { width =128, height =122, numFrames=2, sheetContentWidth=128, sheetContentHeight=256  } 

local catImageSheet = graphics.newImageSheet(“cat_running.png”, catSheetData)

    

local sequenceCatData = { {name=“catRun”, start=1, count=2, time=750} }

    

local runcat = display.newSprite(catImageSheet, sequenceCatData)

runcat.x = display.contentWidth/2 ; runcat.y = display.contentHeight/2    

runcat:scale(0.3, 0.3)

runcat:setSequence(“catRun”)

runcat:play()

This is code correct

–================================================================================================

local catSheetData = { width =128, height =122, numFrames=2, sheetContentWidth=128, sheetContentHeight=256  } 

local catImageSheet = graphics.newImageSheet(“cat_running.png”, catSheetData)

    

local sequenceCatData = { {name=“catRun”, start=1, count=2, time=750} }

    

local runcat = display.newSprite(catImageSheet, sequenceCatData)

runcat.x = display.contentWidth/2 ; runcat.y = display.contentHeight/2    

runcat:scale(0.3, 0.3)

runcat:setSequence(“catRun”)

runcat:play()