I'm trying to write some code that will go through the world and remove all instances of a "Spotlight" object. I accomplish this via this method:
The problem is that this throws the greenfoot.ActorRemovedFromWorld exception. Unlike other community posts I found, my method references the World as a static World object ("w", "MyWorld.w"), meaning that since I know it's can't be an actor trying to reference getWorld() because it's static, I'm completely at a loss. Any help would be much appreciated.
public static void reset() { List theList = MyWorld.w.getObjects(Spotlight.class); for (Object m: theList) { MyWorld.w.removeObject((Actor)m); } }