Page 1 of 1

function ChangeAnimation2 - UPDATED

PostPosted: Fri Jul 11, 2008 5:08 am
by feral
NOTE: This is the OLD version use to be called animclone - now called ChangeAnimation2() - check next post

I just realized you cannot set the animation of clones using getclone ??

if this is true, then here is a function that will get around that.

it allows any actor to set the animation of any clone

to use: place the following function in a global script
then in ANY actor use the function as

animclone("clonename",cloneindex,"nameofanimation","DIRECTION")

where clonename,nameofanimation, and DIRECTION are enclosed in double quotes ( or strings vars)
and cloneindex is an int.

"DIRECTION" should be "STOPPED","BACKWARD", or "FORWARD"
example

animclone("ship",3, "explosion","FOWARD") // changes the animation of ship.1 to the explosion animation going forward..

if it doesn't make sense (or isn't needed, because there is a better way) let me know..

NOTE :Currently does NO checking, and ChangeAnimation() is very happy to process rubbish, so if your animations do not work, double check all your spelling..

feral

Code: Select all
void animclone(char *actor,int i,char *name, char *dir)
{
char cloneID[50];
sprintf(cloneID,"%s.%i",actor,i);
  if (strcmp(dir,"STOPPED")==0)
    {
      ChangeAnimation(cloneID, name,STOPPED);
    }

  if (strcmp(dir,"FORWARD")==0)
    {
      ChangeAnimation(cloneID, name,FORWARD);
    }

  if (strcmp(dir,"BACKWARD")==0)
   {
     ChangeAnimation(cloneID, name,BACKWARD);
   }
}

Re: function ChangeAnimation2

PostPosted: Fri Jul 11, 2008 5:10 am
by feral
This is an updated version and works more like Changeanimation

as it does work like ChangeAnimation and uses the same idea as getclone2... I decided to change the name

now called ChangeAnimation2()

in global place function
Code: Select all

void ChangeAnimation2(char *actor,int i,char *name, const int dir)
{
char cloneID[50];
sprintf(cloneID,"%s.%i",actor,i);
ChangeAnimation(cloneID,name,dir);
}



To USE:

ChangeAnimation2("clonename",index,"animationstring",DIRECTION);

where
clonename is name of clone in "quotes" or as a string var
index is the index number of the clone to change
animationstring is the name of the animation to change to in "quotes" or as a string variable
DIRECTION = FORWARD,BACKWARD,STOPPED or NO_CHANGE - quotes are NOT required in this version - use just like ChangeAnimation()


BTW: let me know if there is anything else getclone().. getclone2() can't do, and I will try to figure something out..
I don't use getclone() myself, so I am not sure of it's limitations..

Re: function ChangeAnimation2 - UPDATED

PostPosted: Sat Aug 02, 2008 9:44 pm
by feral
note: the same thing could have been achieved simply by using my cloneID() function and the regular ChangeAnimation

eg:

ChangeAnimation(cloneID("clonename",index),"animationname",FORWARD )

see viewtopic.php?f=5&t=5931

Re: function ChangeAnimation2 - UPDATED

PostPosted: Mon Aug 04, 2008 1:59 pm
by Game A Gogo
very nice! never noticed this, but I shall remember this :3
thank you