A simple domain specific language could help; create an AnimationDirector class that would interpret the statements from the animation script and do the appropriate work during Draw
and Update
. The DSL itself could be as simple as
texture 0,0; 800,600; 5.0
which will create an object with texture texture
at (0,0) and move it to (800,600) over a 5 second period, and then destroy it.
If you want something a little more useful,
create x texture 0,0
over 5.0 move x 800,600
destroy x
which will let you get more creative, and expand the possibilities of animation (such as adding rotation, etc. if you desire such).
Now, when you need to run an animation, just pass the appropriate resource name to the director, and let it handle things from there. Alternatively, you could create some kind of AnimatedEntity which refers to a particular script, and calls the AnimationDirector itself for Draw
and Update
; depending on how you've done your engine so far, this might be more fitting to its design.