Play animations in a row

Hi everybody!
Im working on some tool, that will allow me to import animations for displayObjects from xml file.

now, the main loop for playing animation looks this way(tweak exmple from http://developer.anscamobile.com/content/animation#comment-42405):

1
2
3
4
5
6
7
8
frameInc = 1
pass = function()
    if frameInc<#v.Frames then
        frameInc = frameInc + 1 
        transition.to(self.image, {time=self.Animation.TimePerFrame, onComplete=pass, x= self.image.x + v.Frames[frameInc].Pos[1], y= self.image.y + v.Frames[frameInc].Pos[2] ... etc)
    end
end
pass()

Now I haven't tested this and I'm a little groggy after a long day, but I believe this should work - try it and let me know, if it doesn't I shall take a good look at it in the morning :)

1
2
3
4
5
6
7
8
9
10
11
local function multiPass (event)
frameInc = 1
pass = function()
    if frameInc<#v.Frames then
        frameInc = frameInc + 1 
        transition.to(self.image, {time=self.Animation.TimePerFrame, onComplete=pass, x= self.image.x + v.Frames[frameInc].Pos[1], y= self.image.y + v.Frames[frameInc].Pos[2] ... etc)
    end
end
pass()
end
timer.performWithDelay(5000, multiPass, 10)

Thanks for answer, Peach! But i did it that way too) i even wrote the function that returned animation duration for me, so i could run performWithDelay with delay equal to animation duration. But i am looking for solving case in which a few animation(maybe different) can spawn in short period of time. And i want them play in a row, one by one...

maybe, i need dispatch event or checking somehow if object plays animation at some point of time and wait till it ends before starting new

views:1545 update:2011/9/28 9:01:40
corona forums © 2003-2011