Page 1 of 1

Get all actors on screen

PostPosted: Thu Mar 15, 2012 3:16 pm
by Hblade
Is there a way I can get all actors on the screen, then have them all do something?

Something like this:
Code: Select all
if(All_actors_On_Screen)
{
    All_actors.r=255;
    etc...
}

Re: Get all actors on screen

PostPosted: Thu Mar 15, 2012 4:18 pm
by Game A Gogo
I think if you have a filled region the size of the view and you use the GetAllActorsInCollision function.

From GE Script documentation wrote:getAllActorsInCollision: Returns an Actor's array that includes all Actors that collide with the cloneName if successful or NULL if there are no collisions.
Actor count will be returned in nActors.
Actor *getAllActorsInCollision(char *cloneName, int *nActors)
cloneName: nameactor.cloneindex (Ex.: ship.1, ship.2, ...), "Event Actor", "Collide Actor", "Parent Actor" or "Creator Actor"
The returned array will be valid until the next call to getAllActorsInCollision.
The returned array is read only.

Script Editor Syntax:
getAllActorsInCollision("Event Actor",&num);

For Example, to make the "Event Actor" the parent of all the colliding actors:

Code: Select all
int n;
Actor *actors;

actors = getAllActorsInCollision("Event Actor", &n);


if(actors)
{
    int i;
    for(i = 0; i < n; i++)
    {
        ChangeParent(actors[i].clonename, "Event Actor");
    }
}


Re: Get all actors on screen

PostPosted: Sun Mar 18, 2012 3:28 am
by Hblade
Thanks