Sprite error

I have a sprite sheet that has the following specifications

png format
2170 x 434
each sprite is 217 X 217
the sprites are 10 on the top row and 10 below for a total of 20

here is my code

local spriteSheetSpinningHead = sprite.newSpriteSheet(“headspin.png”, 217, 217)
local spriteSetHeadSpin = sprite.newSpriteSet(spriteSheetSpinningHead,1,20)

I get the following error
“sequence frames must be inside the sheet”

[import]uid: 28709 topic_id: 15476 reply_id: 315476[/import]

I have tested your code and I am not getting that error.

Make sure you have included at the top :

local sprite = require(“sprite”)

Other thing I noticed that the image size (2170 X 434) used by you is large and it shows white box in the simulator instead of the image/animation. Try reducing that size. [import]uid: 88119 topic_id: 15476 reply_id: 57204[/import]

The only way to reduce the size is to use less images in the sequence which I had already thought about.

Is there a limit to how many sprites are on a sprite sheet?

Is the two rows of 10 images layout ok?
[import]uid: 28709 topic_id: 15476 reply_id: 57228[/import]

Hey guys,

That isn’t the only way to reduce the size. 2170 is too large.

Could you not simply rearrange your sheet so it was in more of a square layout? You really want sprite sheets below 1024 x 1024.

Peach [import]uid: 52491 topic_id: 15476 reply_id: 57241[/import]

So, should I make the sprites smaller and then scale them larger when I create the new instance?
Update, I tried this and it worked but the sprites pixelated terribly…
[import]uid: 28709 topic_id: 15476 reply_id: 57261[/import]

I think peach is trying to say make it more of a square and not a rectangle as it is right now and in the process take the size under 1024. Instead of having only 2 rows have more rows and increase its height and reduce the width. [import]uid: 88119 topic_id: 15476 reply_id: 57263[/import]

I understood that.

So if I have say thirty sprites in a sequence I should spread it across multiple sheets?
[import]uid: 28709 topic_id: 15476 reply_id: 57280[/import]

yes in one of the blog post it is mentioned that we will have to use multiple sprite sheets

see the last section in this post

http://blog.anscamobile.com/2011/01/dynamic-image-resolution-made-easy/ [import]uid: 88119 topic_id: 15476 reply_id: 57282[/import]

Yes, you can use multiple sheets.

However if you have 30 images in a sheet, you could have 5 rows each with 6 sprites, like this;
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X

That way the image wont be as wide - but if you can’t do that and have it not over the limit mentioned above, then combine multiple sheets.

Link to API here; http://developer.anscamobile.com/reference/index/spritenewspritemultiset

Peach :slight_smile: [import]uid: 10144 topic_id: 15476 reply_id: 57370[/import]