how can I use the function" getclone"

Questions, comments and discussion about the Game Editor development.

how can I use the function" getclone"

Postby walkman » Tue Aug 17, 2010 3:10 am

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 .
walkman
 
Posts: 6
Joined: Mon Aug 09, 2010 9:51 am
Score: 0 Give a positive score

Re: how can I use the function" getclone"

Postby DST » Tue Aug 17, 2010 4:03 am

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);
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: how can I use the function" getclone"

Postby walkman » Tue Aug 17, 2010 5:30 am

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.
walkman
 
Posts: 6
Joined: Mon Aug 09, 2010 9:51 am
Score: 0 Give a positive score

Re: how can I use the function" getclone"

Postby DST » Tue Aug 17, 2010 10:33 pm

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);
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: how can I use the function" getclone"

Postby tintran » Sun Dec 26, 2010 10:13 pm

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.
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest