Best Practices for Sequential Events?

Hey All:

In building my apps, I’m faced with situations where I need to fire off multiple events sequentially with some delay in between, and the need to track when an events have completed. So far I’ve been using timer.performWithDelay for individual events, but I’m not sure how to use this in a situation that needs to manage 5 to 10 or more events.

For example, let’s say you want to display 5 animations sequentially. Start anim 1 (which runs 10 seconds), wait 2 seconds until anim 1 has completed, start anim 2 (which runs 5 seconds), wait until anim 2 has completed, start anim 3, etc. What is the best way in Corona to string together multiple events with delays in between?

Thanks for any suggestions. [import]uid: 6756 topic_id: 4679 reply_id: 304679[/import]

I would like a “correct” way to do this too… Any hints out there? [import]uid: 13801 topic_id: 4679 reply_id: 23034[/import]

Yeah, I’m still looking for some kind of clarification on this, and the docs don’t make it clear whether timer.performWithDelay is the right (only?) way to do this. I’ve started using another development tool because I can’t figure out the proper way to manage multiple events in Corona. [import]uid: 6756 topic_id: 4679 reply_id: 23040[/import]

Saying 5 “animations” is pretty vague, since “animation” can mean multiple things.

For example, if you mean a transition, then set the onComplete parameter.

If you mean a sprite, listen for the “end” event:
http://developer.anscamobile.com/reference/index/spriteinstanceaddeventlistener [import]uid: 12108 topic_id: 4679 reply_id: 23046[/import]

I currently have a series of animations. What I mean by this is I have one sprite sheet, and from it I am pulling a few sprite sets. One example where I am having trouble specifically is this:

There is a boy standing in a looping sprite set. I have a second set, where he turns his head to look at the quiz questions that are on the screen. Finally, I have a third set which is the reverse of set two, giving the appearance of him rolling his head back to face the player again.

The ideal setup would be:
1.standing(base, all animations start off this)
2.look towards questions
3.pause for a bit
4.look back at the player.

I have a few instances where this would also apply, like my character putting on, and taking off a mask.

What would be the best way to do this? I currently have each animation creating a listener, which at the end of its play, calls a function with the next sprite set to play.

The problems I am having are:
1.complex, hard to read code (lots of listeners)
2.third sequence isn’t playing, and is being skipped (For instance in the example above, the character looks at the questions, and then ‘snaps’ back to the idle animation, without playing the second “look back to player” set. I read something about the screen not being updated in blocks, could this be the cause?)

I am sure I am doing this way wrong… but I don’t know a better way. Thoughts? [import]uid: 13801 topic_id: 4679 reply_id: 23127[/import]

Can anybody comment on this? I’m sure there are much better ways to do this than what I am trying. [import]uid: 13801 topic_id: 4679 reply_id: 23489[/import]