function ChangeAnimation2 - UPDATED

You must understand the Game Editor concepts, before post here.

function ChangeAnimation2 - UPDATED

Postby feral » Fri Jul 11, 2008 5:08 am

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);
   }
}
Last edited by feral on Sat Aug 02, 2008 9:37 pm, edited 2 times in total.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: function ChangeAnimation2

Postby feral » Fri Jul 11, 2008 5:10 am

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..
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: function ChangeAnimation2 - UPDATED

Postby feral » Sat Aug 02, 2008 9:44 pm

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
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: function ChangeAnimation2 - UPDATED

Postby Game A Gogo » Mon Aug 04, 2008 1:59 pm

very nice! never noticed this, but I shall remember this :3
thank you
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest