I’m back with more obvious questions!
It feels like I’ve been skirting near the answer to this for days but just haven’t got it working …
I want to show a series of animations that all play sequentially (one after the other). Some of these animations are dynamically generated and so I don’t know the length of each animation - so I can’t use timer.performWithDelay
I’m using Sprite Grabber and I see that sprites can fire events, but I’m a bit confused about the sprite phase “end” vs. the general event phase of “ended”. Either way, I can’t seem to implement anything that works. I’ll paste what I’m trying to do below but really this seems overkill even if it does work. I don’t want to have to fire a function on each sprite clip completing.
THEN i saw there’s a spriteInstance of “animating” (http://developer.coronalabs.com/reference/index/spriteinstanceanimating). This would appear to do the trick … If I could do something like
[blockcode]
if (not spritesequence1.animating) then
spritesequence2:play()
end
if (not spritesequence2.animating) then
spritesequence3:play()
end
… and so on
[/blockcode]
But that doesn’t seem to work either. Do I need a listener here? It could be my messy code botching things up - all this is taking place inside another large function (which is why I’m keen on the most efficient approach to give me the best chance of untangling it all!)
Anyway, here’s my Listener solution, which is all shades of ugly and messed up:
[blockcode]
local animationend = false
local function continue()
if sprite.phase == “end” then
animationend = true
end
end
spritesequence1:addEventListener(“sprite”, continue)
– then later on I check
if animationend == true then
spritesequence2:play()
end
[/blockcode]
So to recap! I need a neat way of saying “when this sprite has reached the end of its animation, go ahead and play this next sprite”
Thanks in advance!
Andrew [import]uid: 132606 topic_id: 31314 reply_id: 331314[/import]
[import]uid: 46570 topic_id: 31314 reply_id: 125158[/import]