Page 1 of 1

Actor reuse?

PostPosted: Mon Jun 24, 2013 7:25 pm
by Lacotemale
Hi all,

Is it possible with GE to re-use actors with a different value or graphic?

For example for an inventory listing it would make more sense to reuse one text actor instead of making new static actors for each item in the list.

Any help appreciated. :)

Re: Actor reuse?

PostPosted: Mon Jun 24, 2013 7:52 pm
by skydereign
Lacotemale wrote:Is it possible with GE to re-use actors with a different value or graphic?

Yes, this is a very important part of making games in gE. Two clones can have different animations. For instance, having the following code will make all item actors have a unique appearance (assuming the actor has the enough animations).
items -> Create Actor -> Script Editor
Code: Select all
ChangeAnimation("Event Actor", getAnimName(cloneindex), FORWARD);

You can do the same thing with animpos as well. And by using some actor variable, you can have the code do different things based off the value (like the use of cloneindex in that example).

Re: Actor reuse?

PostPosted: Fri Jun 28, 2013 6:17 pm
by Lacotemale
So currently I have this:

Code: Select all
ID = inventory[0][0];
AMOUNT = inventory[1][0];
setItemName(ID,AMOUNT);


Does that mean I could do something like this inside my text actor and simply clone it?

Code: Select all
ID = inventory[0][cloneindex];
AMOUNT = inventory[1][cloneindex];
setItemName(ID,AMOUNT);


Also I know I can use moveTo with actors but can this also function for clones?

Re: Actor reuse?

PostPosted: Fri Jun 28, 2013 6:48 pm
by skydereign
Lacotemale wrote:Does that mean I could do something like this inside my text actor and simply clone it?

Yes, assuming that is what you want. There is no trickery involved in this. If those values of inventory using cloneindex are the values you want, then it will work.

Lacotemale wrote:Also I know I can use moveTo with actors but can this also function for clones?

Clones are actors. Calling a function on a clone means you pass the function the actor's clonename. Passing "test" into a function will either target all actors named test, the newly created one, or the lowest indexed one, depending on the function and where it is called. Using the clonename, you can make sure to target the specific one, for example "test.4" will target the fifth clone if it exists. The clonename variable is just name.cloneindex.