Page 1 of 1

Referencing actors by their variables?

PostPosted: Sun Jul 08, 2012 5:14 pm
by Kalladdolf
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".

Re: Referencing actors by their variables?

PostPosted: Sun Jul 08, 2012 6:17 pm
by skydereign
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).

Re: Referencing actors by their variables?

PostPosted: Sun Jul 08, 2012 9:17 pm
by Kalladdolf
Thanks, I'll see how that works.