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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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() |
Change line 7 to this;
sprite.add( santaRunSet, "run", 15, 8, 400, -2)
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 :)
Oooohhhhh! Thank you Peach! Ansca is lucky to have you helping people on the Corona SDK forums!
Not a problem at all - thanks for the very kind words, I really appreciate that.
Peach :)
-