This site requires JavaScript, please enable it in your browser!
Greenfoot back
Blight
Blight wrote ...

2012/1/26

Remove all but one actor

Blight Blight

2012/1/26

#
Hi, Is there a way that you can remove everything from the world except one class? Like remove everything except the player. Thanks in advance.
sp33dy sp33dy

2012/1/26

#
Hi Blight. Looking through the options in an extended world class, you have the following option: removeObjects(Collection) - where Collection is the list of objects to remove further to this there is this: getObjects(class) - which will return you a list of all objects if class is set to null or all the objects of class type (i.e. actor.class). Between these two, you should be able to figure out what to do. i.e. get the list of objects to be removed, trim down items from that list and then ask the removeObjects to do the work. I hope this helps nudge you in the right direction. If I've missed the point, do let me know... Regards sp33dy.
You need to login to post a reply.