Malefic Games, independent game developer

If you program games or real time simulation you probably found yourself trying to achieve sequential executions(do this, then this, wait to finish this…) in the step/update function of your code. How many times have you write code that checked if you are at the end of an animation to do something else after that? You can overcome this problem using ifs and flags, if your list of things to do sequentially is short. But we all know that short term solutions can turn into horrible nightmares if the extrapolate the same pattern of adding more ifs and variables.

THE PROBLEM

Generate an easy way to execute functions sequentially. Execute one function, wait until it’s done, execute the next function until there are no more functions to execute.

PROPOSE SOLUTION(for haxe/as3)

Generate a class that handles the problem! So my solution is quite simple, just create a class that store the functions to be executed and execute them one at a time.
The first thing we need to know is when a function has finish. To do this we simply return a bool in all the functions. If we finish doing what we needed to do in the function we return true, if not we return false.

Here an example how to manually loop an animation using the SequenceCode class