Changing animation-sequences of sprites

i have a little problem animating my sprites.
every game-object has several animator-objects
each storing a list of animation-frames for a
special sprite-movement. these animator-objects
can differ through nested classes, so theres one
for looping animation, one for one-shot and so
on.

now imaging my “main-class”, my game-manager, which
schedules all game-objects. if an event occurs, e.g.
pressing a key, collision, whatever, the gamemanager
signals it to the game-objects so that they know,
they have to change the animation-strip.

for getting the correct animationstrip there is an
object which gets a reference of the actual animation.
so the animator-object actual_anim is set to shoot_anim,
walk_anim … whatever shall be returnd for painting
over this dummy.

but now the big problem:
every call to an object that it shall change its animation
is done just in time. imaging a memory card game:
the first “animation” is a card, where you can only see the
deck-motive. after clicking, the card shall turn in a
little animation and then change its animation to a
“heart 8” (or whatever). my program would solve it this way:

animation references to ‘hidden_card’
click on card recognized => animation is set to ??
either : open_card – now the turn-animation is missing
or : turn_card – no i have to develope a system which
detects when the turn_animation has ended and through which
animation it sould be replaced (it hasnt to be always the same
in all cases)

the turn_animation has no clue, that is going to be replaced.
even if it did so it would not know, which animation should
follow…

Im not exactly sure I understand what your problem is, but what you are describing sounds very much liek a finite state machine (FSM.)

An FSM has static states, and transitions defined that take it from onbe state to another. So your “Covered card” woudl be one state, your flip the transition, and the exposed card the next state.

How you code this is up to you but typically the way it is done is with an anim structure that throws an event when it hist its last frame. Do you start the transition anim, wait for it to throw the doen event and then doe the new-state animation.