Delete all actors on layer?

teacherpeter

  • Posts: 12
I'm working on a randomization engine for room layouts. At the start of the game there will be tons of layers, so the game will take time to load of course, but then the game will randomly pick a few layers to work with as the level's layout.

Well, obviously just hiding the other layers wouldn't be enough. I need to delete those layers completely, or at least everything on them, or the game will proceed very slowly.

How would I do that?

Thank you!

DigitalMan

  • *
  • Posts: 12
Did you ever figure out a way to clear a layer? I'm in the same boat. I need to either clear a layer by name or remove and recreate my layer. Removing and recreating is giving me a null reference error (assuming because the "create background layer" block wants a named background).

t4u

  • Posts: 418
Solution 1:
Everyt time you create actor add him to List_of_actors
         As you set actor on layer change actor's attribute layer

Trigger event on destruction of layer
        Go thorugh List_of_actors
                 If get layer from element of list = number of  layer you want to destroy
                     kill actor
                     remove element from list

Solution 2 (probably bette rbut mnore difficult):
Create Layer_List
Layer_List = list of actors on layer_X (you need to take car eof adding to proper list after creating actor)
       When you want to remove layer i
               Get temporar_list = Layer_List
                         For each element in temporary_list
                                  kill element
               
USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/