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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 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 ; } } } |