A simple way to change animations using the animation name only
in global
void ChangeAnim(char *string)
{
ChangeAnimation("Event Actor",string, NO_CHANGE);
}
In draw actor OF event actor
ChangeAnim("fire");
however if you want to use maths to swap them
ie:
animindex=animindex+1
because if you delete an animation and add it again later it may not be the same index number..
Using maths to cycle thru or select an animation indexto do this you really need to setup your own index (which is a good idea anyway, because of the when animations are deleted and rebuilt later the animation index can can get out of order)
so
in global
create a string array large enough to hold all your animations for a character
- Code: Select all
char *player_animindex[10]; //for 10 animations
then in the "create actor" of the player
setup the index ( this gives you control of the order of the index as well..which helps when using maths)
- Code: Select all
player_animindex[0]="runleft"; //actual name of the animations ie as used in ChangeAnimation
player_animindex[1]="runright";
player_animindex[2]="die";
player_animindex[3]="shoot";
then create a global function
- Code: Select all
void ChangeAnim(int index)
{
ChangeAnimation("Event Actor",player_animindex[index], NO_CHANGE);
}
now to change the animindex in the draw event of the player
- Code: Select all
ChangeAnim(2); // or the desired index
or
ChangeAnim(variable); // where variable = the desired index and can then be modded using maths/logic etc
of course this only works for the player( or a particular actor) .. and must be called in the draw event of the player,/actor but if it looks useful I can make it more generic so you can call animations for any actor.. let me know..