hei,
an actor in a game has:
The actor should fahre() while zielErreicht not true BUT if on the way to the Ziel a Bodenloch the act() of the actor should stop. Problem: the actor dont move but the Programm runs endless.
How can i stop it?
I tryed Greenfoot.stop() in fahre() but not work. And now?
class Auto { public void act(){ while ( zielErreicht() == false ) { fahre(); } } public void fahre(){ if ( bodenlochVorhanden() == false) { move(1); Greenfoot.delay(3); } else { Greenfoot.stop(); } } public boolean bodenlochVorhanden() { if(getOneIntersectingObject(Bodenloch.class)!=null) { return true; } return false; } public boolean zielErreicht() { if(getOneIntersectingObject(Ziel.class)!=null) { return true; } return false; } }