You can store the pointer to an actor, and you can use an array of pointers like:
- Code: Select all
Actor **myactors;
But you need to control the allocation of the array:
- Code: Select all
myactors = (Actor **)malloc(MAX_ACTORS*sizeof(Actor**));
Where MAX_ACTORS can be defined by you.
Other way is use some data struct, like a linked list to make more good use of the memory (you only alloc what you need).
In any case, you need to update the array when an actor is destroyed (In the Destroy Actor event).
You need to get a pointer to the event actor:
- Code: Select all
Actor *eventActor = getclone(clone name of the event actor);
And update the array:
- Code: Select all
RemoveActorFromMyArray(eventActor);
What you will do in the RemoveActorFromMyArray function depends of the data structure used.
If you have used an array, you need to scan the array until get a entry thats have the eventActor pointer and make this entry NULL.
If you have used a map (hash tables, ...) you can make this process faster!