Playing two different sprites one after another

Due to the size limitation of sprite sheets being 2048 x 2048, I have 6 sprite sheets that combined will be a 4 second animation.

How can I accomplish this?

I’ve tried transition.to and timer.performWithDelay with no luck.

My transition.to code resulted in just the first frame of the second sprite being displayed.

Also, I can’t get my sprites to not loop. No matter what I try, they loop forever.

Here’s my basic spriteGrabber code:

local play1 = grabber.grabSheet(“part_1”)
local playanimation1 = play1:grabSprite("", true, {clip1 = {1,18,600,1} })
local play2 = grabber.grabSheet(“part_2”)
local playanimation2 = play2:grabSprite("", true, {clip2 = {1,20,667,1} })

Thanks for any help.

[import]uid: 38758 topic_id: 9358 reply_id: 309358[/import]

Or better yet. Is there a way to load the 6 sprite sheets into one object that can then be played? [import]uid: 38758 topic_id: 9358 reply_id: 34217[/import]

I’ve kind of got it working using this code:

playanimation2:hide()
playanimation3:hide()
playanimation1:play()
timer.performWithDelay(600, function() playanimation2:show() playanimation2:play() end)
timer.performWithDelay(1267, function() playanimation3:show() playanimation3:play() end)

However, the animation is jumpy. I was hoping for a smooth transition between sprites.

Is there a way to combine multiple sprite sheets into one object? [import]uid: 38758 topic_id: 9358 reply_id: 34219[/import]

Figured it out using sprite.newSpriteMultiSet

http://developer.anscamobile.com/reference/index/sprite

There’s not much documentation on this one, but I just used the sample code and changed the names.

I used TexturePacker to create my spriteSheets [import]uid: 38758 topic_id: 9358 reply_id: 34336[/import]

I too am using newSpriteMultiSet, however, when I transition from an animation on one page to another, I get a glitch in the artwork.

Were you able to get around this issue? If so, then my problem is probably in my code.

Can you share a peek at your code so I can compare? Here’s mine:

[code]
local spriteSet2 = sprite.newSpriteMultiSet(
{
{ sheet = anim1Sheet, frames = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 } },
{ sheet = anim2Sheet, frames = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 } }
}
)

sprite.add( spriteSet2, “anim1”, 1, 15, 1000, 0 )
sprite.add( spriteSet2, “anim2”, 16, 18, 1000, 1 )

local p1Hero = sprite.newSprite( spriteSet2 )
p1Hero:setReferencePoint(display.BottomCenterReferencePoint)
p1Hero.x = (270); p1Hero.y = (375);
p1Hero.xScale = (1.0); p1Hero.yScale = (1.0);

p1Hero:prepare( “anim1” )
p1Hero:play( “anim1” )

local function playanim2 (event)
p1Hero:prepare( “anim2” )
p1Hero:play( “anim2” )
end

local function returnToanim1 (event)
if event.phase == “end” then
p1Hero:prepare( “anim1” )
p1Hero:play( “anim1” )
end
end

p1Hero:addEventListener( “tap”, playanim2 )
p1Hero:addEventListener( “sprite”, returnToanim1 )
[/code] [import]uid: 45878 topic_id: 9358 reply_id: 35248[/import]

Here’s my code. I got it to work except not to my liking. I needed to loop once. I created a workaround to get to appear to loop once, bu the code did not consistently work. It would work, then I’d run it again (same code) and the sprite would keep showing a loop. I’ve trimmed the code below just to show the portion of getting the multisheet to work. I’m very much a noob at this so the code my not be the best structure-wise. The big series of 8s on the last one to simulate freezing on the last frame since I could figure out how to do that correctly.

[blockcode]

local localGroup = display.newGroup()

local play1 = sprite.newSpriteSheetFromData( “img_6a1.png”, require(“img_6a1”).getSpriteSheetData() )
local play2 = sprite.newSpriteSheetFromData( “img_6a2.png”, require(“img_6a2”).getSpriteSheetData() )
local play3 = sprite.newSpriteSheetFromData( “img_6a3.png”, require(“img_6a3”).getSpriteSheetData() )
local endFrame = sprite.newSpriteSheetFromData( “img_6a3.png”, require(“img_6a3”).getSpriteSheetData() )

local spriteSet2 = sprite.newSpriteMultiSet(
{
{ sheet = play1, 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 } },
{ sheet = play2, 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 } },
{ sheet = play3, frames = { 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8} }
}
)
local spriteSet = sprite.newSpriteMultiSet(
{
{ sheet = endFrame, frames = { 8 } }
}
)

local instance2 = sprite.newSprite(spriteSet2)
instance2.x = display.contentWidth / 2
instance2.y = display.contentHeight / 2
instance2:play(“animation”)
localGroup:insert(instance2)

[/blockcode]
[import]uid: 38758 topic_id: 9358 reply_id: 35334[/import]