Sprite Disapperaing using Sprite Sheet Set

Hello Corona Community!

I have a problem using the newSpriteSet. I combined a 22 sprites: 1-14 of jumping and 15-22 of running. The problem with this is when I use the “run” sprite set, the sprite disappears and then restarts. I’ve attached a link to a YouTube video showing what’s happening. Is there a work-around or is there something wrong with my code?

http://youtu.be/29861VEVnPo

local sheetData = require ('santa')  
 local data = sheetData.getSpriteSheetData()  
 local spriteSheet = sprite.newSpriteSheetFromData( "images/santa.png", data )  
  
 local santaRunSet = sprite.newSpriteSet(spriteSheet, 1, 22)  
 sprite.add( santaRunSet, "jump", 1, 14, 500, -2)  
 sprite.add( santaRunSet, "run", 15, 22, 400, -2)  
  
 local santa = sprite.newSprite( santaRunSet )  
 santa.x = 280  
 santa.y = 100  
  
 physics.addBody( santa, "dynamic", { friction=0.5, bounce=0.3 } )   
  
 santa:prepare("run")  
 santa:play()  

[import]uid: 14218 topic_id: 18013 reply_id: 318013[/import]

Change line 7 to this;
[lua]sprite.add( santaRunSet, “run”, 15, 8, 400, -2)[/lua]

You had 15, 22 - which says you want to start that sequence at frame 15 and go for 22 frames. You in fact want to start at frame 15 and play 8 frames. (15 to 22 = 8 frames, including frame 15.)

TLDR; The second number is how many frames in the sequence, NOT the number of the final frame in the sequence.

Try that - should fix it up.

Peach :slight_smile: [import]uid: 52491 topic_id: 18013 reply_id: 68877[/import]

Oooohhhhh! Thank you Peach! Ansca is lucky to have you helping people on the Corona SDK forums! [import]uid: 14218 topic_id: 18013 reply_id: 69033[/import]

[import]uid: 89165 topic_id: 18013 reply_id: 68840[/import]

Not a problem at all - thanks for the very kind words, I really appreciate that.

Peach :slight_smile: [import]uid: 52491 topic_id: 18013 reply_id: 69072[/import]