Page 1 of 1

how can I use the function" getclone"

PostPosted: Tue Aug 17, 2010 3:10 am
by walkman
I want output the information of all actes in my game to txt file.How can I get the actes' information? Use the "getclone" function? But, which type is the fuction's return value?

thanks very much .

Re: how can I use the function" getclone"

PostPosted: Tue Aug 17, 2010 4:03 am
by DST
The type is Actor*

Code: Select all
Actor * this =getclone("enemy.1");
int xx=this->x;


this is an Actor *.
To run functions on this, use it's clonename
Code: Select all
Actor * this =getclone("enemy.1");
char thisactor[32];
strcpy(thisactor, this->clonename);
DestroyActor(thisactor);

Re: how can I use the function" getclone"

PostPosted: Tue Aug 17, 2010 5:30 am
by walkman
ok, thanks.
another question:

Is this Actor and Actor object in game-engine same? Can the functions of the Actor in game-engine be called in Game Editor script in this way?
for example:

one function of actor in game-engine like this: void ProcessQueueActions();
In Game Editor Script I have some code like this:
Actor* pact = getclone("enemy.1");

can I call the function like this?
pact->ProcessQueueActions()?


Thanks.

Re: how can I use the function" getclone"

PostPosted: Tue Aug 17, 2010 10:33 pm
by DST
For built in GE functions, must copy actor->clonename to a string, and run the function with that, as in the previous example.

For custom functions, this depends on the function you have created.

For instance,

void dosomething(Actor * this, int aa)}
}

Then call

dosomething(pact, pact->x);

Will work because you are inputting the declared variable type that the function requires.



Yes, this is the same Actor as all GE Actors, but they are temporary versions.



Also, you can call them by variable cloneindex if you use the getclone2 function (getclone1 needs specific cloneindex);


GetClone2 by Jazz-E-Bob
Code: Select all
Actor *getclone2 ( char *actorName, long cloneNumber )
{

  char resultString[256] = "";
  char cloneNumberAsString[10];
  Actor *resultActor;

  strcpy ( resultString, actorName );
  strncat ( resultString, ".", 1 );
  sprintf (cloneNumberAsString, "%i", cloneNumber);
  strncat  ( resultString, cloneNumberAsString, 10 );

  resultActor = getclone(resultString);

  return resultActor;

}


then in a loop, you can use

pact=getclone2("pact", i);

Re: how can I use the function" getclone"

PostPosted: Sun Dec 26, 2010 10:13 pm
by tintran
thought i'd share this, since it's a bit shorter :) (and it does the same as getclone2 from above).
Code: Select all
Actor *getclone3(char *actorName, long cloneIndex)
{
  char cloneName[256];
  sprintf(cloneName,"%s.%d",actorName,cloneIndex);
  return (getclone(cloneName));
}

it's only if you want to do something with the clone.
if all you want to do is simply want to draw_from the clone, you can use the below function.
Code: Select all
void draw_from_clone(char *actorName,long cloneIndex,float x, float y,float scale)
{
  char cloneName[256];
  sprintf(cloneName,"%s.%d",actorName,cloneIndex);
  draw_from(cloneName,x,y,scale);
}


and if you're a little bit more of a "cpu milker" wanna be (which i try to be) :)
you can declare a char cloneName in your variables declaration part like, for example: I have a void paintCanvas() function as below which draw_from all the clones of an actor that's named as "bg".
Code: Select all
void paintCanvas()
{
  int i;
  char cloneName[256];

  for (i=0;i<ActorCount("bg");i++)
  {
    sprintf(cloneName,"bg.%d",i);
    draw_from(cloneName,view.width/2,view.height/2+i,z[i]);
  }
}

----------------------
by the way, DST. how long have you been making games for? I checked out your site a little, holy @$# dude (assuming you're a dude) you got a lot of games.