Device build crashes with sprite animaiton

Hello

Trying to get my game to work out on my Android phone, but it keeps crashing. Have now found out that my sprite animation is the root of the problem.

It crashes on the second line, anyone understands why, can’t see where I’m going wrong!!!

local spriteSheetPlayer = sprite.newSpriteSheet(“sheetPlayer.png”, 50, 100);
local spriteSetPlayer = sprite.newSpriteSet(spriteSheetPlayer, 1, 30);

Have also tried to have the sheetPlayer.png both placed in the same folder as my main.lua file and in a sub-folder, where I originally had it.

Thanks in advance! [import]uid: 95786 topic_id: 22030 reply_id: 322030[/import]

You aren’t adding a sequence. See this sample code;

[lua]-- A sprite sheet with a cat
local sheet1 = sprite.newSpriteSheet( “runningcat.png”, 512, 256 )

local spriteSet1 = sprite.newSpriteSet(sheet1, 1, 8)
sprite.add( spriteSet1, “cat”, 1, 8, 1000, 0 ) – play 8 frames every 1000 ms

local instance1 = sprite.newSprite( spriteSet1 )
instance1.x = display.contentWidth / 4 + 40
instance1.y = baseline - 75
instance1.xScale = .5
instance1.yScale = .5

instance1:prepare(“cat”)
instance1:play()[/lua]

That is from CoronaSDK > SampleCode > Sprites > JungleScene

See how sprite.add is used before setting up the actual sprite? :slight_smile:

Peach

PS - Are you getting simulator errors with your code? [import]uid: 52491 topic_id: 22030 reply_id: 87628[/import]

In fact, I have actually set up actions and there are no errors in the simuator, works perfect. Problem is when I build it for the device(HTC Desire) it wont work.

Have commented out all of the code, and found out that if It is that sprite.newSpriteSet… line that causes the error, if I comment that one out (and the actions etc.) it works perfectly.

Are there anything about the image maybe? It is a 300x500 png, anything thing that aren’t allowed with image type, bit size etc??? [import]uid: 95786 topic_id: 22030 reply_id: 87669[/import]

Oh OK - for future reference when you post code you should post all relevant code, else it appears there are errors :wink:

The image size should be OK - anything under 1024x1024 should be cool on any device we support.

Just to clarify though, 300x500 is the size of the sheet, not of just one frame, correct?

If you want to upload a sample somewhere (you can add a watermark to your sprite if you want) I’d be happy to take a closer look.

:slight_smile: [import]uid: 52491 topic_id: 22030 reply_id: 87780[/import]

Figured it out!

Had somehow named my texture sheetPlayer.PNG(!!!), and referred to it as sheetPlayer.png, that was the thing that crashed it.

[import]uid: 95786 topic_id: 22030 reply_id: 87925[/import]

Ah I see! Well done on figuring it out.

I’m interested to hear that it didn’t give a corrupted error which is what normally happens with the capital letter issues that come up sometimes - so this is definitely useful info for me.

Thanks!

Peach :slight_smile: [import]uid: 52491 topic_id: 22030 reply_id: 88005[/import]