Referencing actors by their variables?

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

Referencing actors by their variables?

Postby Kalladdolf » Sun Jul 08, 2012 5:14 pm

Situation: A game session has about 480 clones simultaneously (give or take) on a mobile device.
Problem: I'd like to avoid giving them a draw actor event (as it would have to be carried out for all of them every single frame) and SendActivationEvent will only work for one of them.
Question: Is there a way of addressing specific ones of them externally by using actor variables properties? As in "Destroy the ActorX, whose xscreen is less than 0".
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Referencing actors by their variables?

Postby skydereign » Sun Jul 08, 2012 6:17 pm

Kalladdolf wrote:Question: Is there a way of addressing specific ones of them externally by using actor variables properties?

Only kind of. Also, SendActivationEvent can target any clone. In 1.5, if you specify an actor name (opposed to a clonename), it will send the event to all clones. This sends an event to only enemy.4.
Code: Select all
SendActivationEvent("enemy.4");

This sends it to all enemies (you do need to maintain the highest cloneindex variable though).
Code: Select all
int i;
char buffer[30];
for(i=enemy.cloneindex; i<=high_cloneindex;i++)
{
    sprintf(buffer, "enemy.%d", i);
    SendActivationEvent(buffer);
}

If you want to only send the event to the actors with xscreen less than 0, you can use getclone2 function, and check the xscreen value (looping the same way as the above code).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Referencing actors by their variables?

Postby Kalladdolf » Sun Jul 08, 2012 9:17 pm

Thanks, I'll see how that works.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest