Hi its me again (its getting embarassing, but i'm a student and a total noob with greenfoot...)
my issue is, that the fruit should fall randomly from the sky and disappear as soon as they touch the ground. This should repeat itself in a loop again and again.
I wrote the code for the class Apple and no syntax error is displayed. Nevertheless this error code appears:
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:681)
at greenfoot.Actor.getOneIntersectingObject(Actor.java:930)
at Apple.act(Apple.java:27)
at greenfoot.core.Simulation.actActor(Simulation.java:594)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
this is now the code for Apple:
Can anyone please help me?
public class Apple extends Actor
{
public Apple()
{
turn(90);
}
/**
*Der Apfel fällt vom Himmel und bringt einen Punkt.
*/
public void act()
{
move(4);
if (isAtEdge())
{
getWorld().addObject( new Apple(), Greenfoot.getRandomNumber (700)+50, 0);
getWorld().removeObject(this);
}
Actor mädchen = getOneIntersectingObject(Mädchen.class);
if (mädchen!=null)
{
Counter counter = new Counter();
((MyWorld)getWorld()).getCounter().addScore();
}
}
}


