For some Reason instead of the Feuerball(Fireball) being removed, when hitting something a window opens itself with error codes because the code couldnt be carried out eventhough the return should stop the code from continuing.
public void act()
{
if (!getWorld().getObjects(Feuerball.class).isEmpty()) {
bewegen();
removeTouching(Abenteurer.class);
}
}
public void bewegen(){
int x=getX();
int y=getY();
int richtung=getRotation();
if (((getRotation()==0) && getOneObjectAtOffset(1, 0, Wand.class) !=null)) {
getWorld().removeObjects(getWorld().getObjects(Feuerball.class));
return;
}
else if (((getRotation()==90) && getOneObjectAtOffset(0, 1, Wand.class) !=null)){
getWorld().removeObjects(getWorld().getObjects(Feuerball.class));
return;
}
else if (((getRotation()==180) && getOneObjectAtOffset(-1, 0, Wand.class) !=null)) {
getWorld().removeObjects(getWorld().getObjects(Feuerball.class));
return;
}
else if (((getRotation()==270) && getOneObjectAtOffset(0, -1, Wand.class) !=null)){
getWorld().removeObjects(getWorld().getObjects(Feuerball.class));
return;
}
else if ((getRotation()==0) && getOneObjectAtOffset(1, 0, Wand.class) ==null){
move('r');
}
else if ((getRotation()==90) && getOneObjectAtOffset(0, 1, Wand.class) ==null){
move('u');
}
else if ((getRotation()==180) && getOneObjectAtOffset(-1, 0, Wand.class) ==null){
move('l');
}
else if ((getRotation()==270) && getOneObjectAtOffset(0, -1, Wand.class) ==null){
move('o');
}
if ((richtung == 90 && x >= 12) || (richtung == 180 && y >= 12) || (richtung == 270 && x <= 0) || (richtung == 0 && y <= 0)) //es wird überprüft, ob der Feuerball den Rand getroffen hat
{
getWorld().removeObject(this);//Feuerball wird entfernt, da dieser nichts getroffen hat und den Rand der Welt erreicht hat
return;
}
}
}
