An error occurs when one of my Ladybugs disappear. It has to do with these methods:Can anyone tell me why that is? Here's the error:
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed.
at greenfoot.Actor.failIfNotInWorld(Actor.java:663)
at greenfoot.Actor.getOneIntersectingObject(Actor.java:912)
at Ladybug.becomingPregnant(Ladybug.java:91)
at Ladybug.act(Ladybug.java:37)
at greenfoot.core.Simulation.actActor(Simulation.java:565)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:523)
at greenfoot.core.Simulation.runContent(Simulation.java:213)
at greenfoot.core.Simulation.run(Simulation.java:203)
public void act() { moveAround(); growOlder(); becomingPregnant(); } private void becomingPregnant() { Ladybug bug = (Ladybug)getOneIntersectingObject(Ladybug.class); if(bug != null && !isOld() && isAdult() && Greenfoot.getRandomNumber(100)==30){ if(bug.isFemale() && bug.isMale()){ gestationPeriod(); } } }