newImageSheet and sheetContentWidth/Height error

Hi,

I am experimenting with newImageSheet and I am getting the following erroe:

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

my code is as follows:

local sheet\_numbers = graphics.newImageSheet("numbers.png", {width = 290, height = 329, numFrames = 28, sheetContentWidth = 109, sheetContentHeight = 124}) local sequence\_numbers = { { name = "allLetters", 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,25,26,27,28 }, time = 500, loopCount = 3, loopDirection = "forward" } } local numbers = display.newSprite( sheet\_numbers, sequence\_numbers )

If I remove  (sheetContentHeight = 124) the error goes away.

My understanding is that sheetContentHeight and sheetContentWidth are used to scale the sprite upon loading (which is what I am trying to achieve).

My image(attached) is a (2030  x 1316) png file. 

Any help with this error is highly appreciated.

Hi @ammar71,

Use

sheetContentWidth = 2030, -- width of original 1x size of entire sheet sheetContentHeight = 1316 -- height of original 1x size of entire sheet

From documentation 

 

sheetContentWidth / sheetContentHeight (optional)

These values tell Corona the size of the original 1x image sheet. For example, if you’re developing for both iPad and iPad Retina, and you’re using an image sheet of 1000×1000 for the regular iPad, you should specify 1000 for both of these values and then design your Retina image sheet at 2000×2000. For more information on this topic, see the Project Configuration guide.

 

Have a nice day :slight_smile:

 

ldurniat

Hi @ldurniat

Thanks for the answer. It seems I miss understood the docs. I was trying to change the size of sprite as it was loaded (i.e. scale it to a smaller size). Basically I use the original size in one scene but I want to make the sprite smaller in another scene. Is this possible upon loading or do I have to scale them as they are displayed? 

I would scale them after creation.

Hi @ammar71,

Use

sheetContentWidth = 2030, -- width of original 1x size of entire sheet sheetContentHeight = 1316 -- height of original 1x size of entire sheet

From documentation 

 

sheetContentWidth / sheetContentHeight (optional)

These values tell Corona the size of the original 1x image sheet. For example, if you’re developing for both iPad and iPad Retina, and you’re using an image sheet of 1000×1000 for the regular iPad, you should specify 1000 for both of these values and then design your Retina image sheet at 2000×2000. For more information on this topic, see the Project Configuration guide.

 

Have a nice day :slight_smile:

 

ldurniat

Hi @ldurniat

Thanks for the answer. It seems I miss understood the docs. I was trying to change the size of sprite as it was loaded (i.e. scale it to a smaller size). Basically I use the original size in one scene but I want to make the sprite smaller in another scene. Is this possible upon loading or do I have to scale them as they are displayed? 

I would scale them after creation.