Get all actors on screen

Game Editor comments and discussion.

Get all actors on screen

Postby Hblade » Thu Mar 15, 2012 3:16 pm

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...
}
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Get all actors on screen

Postby Game A Gogo » Thu Mar 15, 2012 4:18 pm

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");
    }
}

Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Get all actors on screen

Postby Hblade » Sun Mar 18, 2012 3:28 am

Thanks
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest