Stencyl 3.4.0 is now out. Get it now!

how to add actor to Engine.engine.allActors

designpeg

  • *
  • Posts: 488
i've used  the code Engine.engine.allActors.clr( actorID ) to remove actors in my game,

can anyone help with the code to add an actor back into the allActors Array?

I've a lot of actors on screen that don't do anything for large parts of the game, and removing them seems to have significantly increased performance, I'd like to go further and remove more actors and then add them back in just before they start to do stuf.

merrak

  • *
  • Posts: 1490
The solution probably lies in this block of code in the createActor( ) function in Engine.hx

Code: [Select]
//Use the next available ID
if(ai.elementID == Utils.INTEGER_MAX)
{
nextID++;
a.ID = nextID;
allActors.set(a.ID, a);
}
else
{
allActors.set(a.ID, a);
nextID = Std.int(Math.max(a.ID, nextID));
}

I've never done it, so I haven't worked out specifics. allActors is not an array. It's an 'IntHashTable'. The documentation is here: https://github.com/polygonal/ds

« Last Edit: May 18, 2017, 11:24:55 am by merrak »

designpeg

  • *
  • Posts: 488
Great, thanks for the info. Hopefully it'll get me a bit further.