I'm not sure if this would be useful to you at all, but it's the latest animation technique I've come across. The great thing about it is that I can control any entities animation simply by calling one function each frame for that entity.

This function would be called from a loop each frame:
handle_animation(1);

Now if at any point I want to change an animation I simply set say:
my.animate2 = 0;
my.animblend = blend;
my.blendframe = walk;

Now the entity will blend to the walk animation and then cycle the walk animation.

To get a little more complex, here is how I am using the code in a game we are currently developing:

Code:

IF (my.move_x != 0 || my.move_y != 0) { //if we are moving
IF (my.animblend == stand) { //if our current animation is stand
my.animate2 = 0;
my.animblend = blend; //blend and cycle to the walk or run animation depending on whether we are holding shift or not
IF ((key_pressed(key_for_str(key__shift)) == on || key_pressed(key_for_str(key__shift2)) == on)) { my.blendframe = walk; } ELSE { my.blendframe = run; }
}
IF (my.animblend == run && (key_pressed(key_for_str(key__shift)) == on || key_pressed(key_for_str(key__shift2)) == on)) {
my.animate2 = 0; //if we are cycling the run animation and are not pressing shift blend and cycle to the walk animation
my.animblend = blend;
my.blendframe = walk;
}
IF (my.animblend == walk && (key_pressed(key_for_str(key__shift)) == off && key_pressed(key_for_str(key__shift2)) == off)) {
my.animate2 = 0;
my.animblend = blend;
my.blendframe = run;
}
handle_footsteps();
} ELSE {
IF (my.animblend > stand) { //if we arn't moving and our current animation is walk or run blend and cycle the stand animation
my.animate2 = 0;
my.animblend = blend;
my.blendframe = stand;
}
}



Code:

DEFINE animate,SKILL31;
DEFINE animate2,SKILL32;
DEFINE animblend,SKILL33;
DEFINE currentframe,SKILL34;
DEFINE blendframe,SKILL35;

DEFINE blend,-1;
DEFINE stand,0;
DEFINE run,1;
DEFINE walk,2;

FUNCTION handle_animations(animation_speed) {
IF (animation_speed <= 0) { animation_speed = 1; }
IF (my.animblend == blend) {
IF (my.currentframe == stand) { ent_animate(my,"stand",my.animate,anm_cycle); }
IF (my.currentframe == run) { ent_animate(my,"run",my.animate,anm_cycle); }
IF (my.currentframe == walk) { ent_animate(my,"walk",my.animate,anm_cycle); }
IF (my.blendframe == stand) { ent_blend("stand",0,my.animate2); }
IF (my.blendframe == run) { ent_blend("run",0,my.animate2); }
IF (my.blendframe == walk) { ent_blend("walk",0,my.animate2); }
my.animate2 += 45 * time;
IF (my.animate2 >= 100) {
my.animate = 0;
IF (my.blendframe == stand) { my.animblend = stand; }
IF (my.blendframe == run) { my.animblend = run; }
IF (my.blendframe == walk) { my.animblend = walk; }
}
}
IF (my.animblend == stand) {
ent_animate(my,"stand",my.animate,anm_cycle);
my.animate += 0.8 * animation_speed * time;
my.animate %= 100;
my.currentframe = stand;
}
IF (my.animblend == run) {
ent_animate(my,"run",my.animate,anm_cycle);
my.animate += 6.8 * animation_speed * time;
my.animate %= 100;
my.currentframe = run;
}
IF (my.animblend == walk) {
ent_animate(my,"walk",my.animate,anm_cycle);
my.animate += 8 * animation_speed * time;
my.animate %= 100;
my.currentframe = walk;
}
}



Last edited by AxysPhenomenon; 07/12/06 11:04.