Actor reuse?

Non-platform specific questions.

Actor reuse?

Postby Lacotemale » Mon Jun 24, 2013 7:25 pm

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. :)
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: Actor reuse?

Postby skydereign » Mon Jun 24, 2013 7:52 pm

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).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Actor reuse?

Postby Lacotemale » Fri Jun 28, 2013 6:17 pm

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?
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: Actor reuse?

Postby skydereign » Fri Jun 28, 2013 6:48 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron