I used getWorld().removeObject to remove FullBar actor class in my Wraith actor class which can be seen in line 13 but it doesn't remove the actor at all. How can i remove my FullBar ?
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 62 63 64 65 66 67 | public void youLose() { Zombie1 zombie1eat = (Zombie1)getOneIntersectingObject(Zombie1. class ); Zombie1R zombie1eatR = (Zombie1R)getOneIntersectingObject(Zombie1R. class ); Zombie2 zombie2eat = (Zombie2)getOneIntersectingObject(Zombie2. class ); Zombie2R zombie2eatR = (Zombie2R)getOneIntersectingObject(Zombie2R. class ); HalfBar halfbar = new HalfBar(); FullBar fullbar = new FullBar(); if ((zombie1eat != null && getNeighbours(getImage().getWidth()/ 2 , false , Zombie1. class ).contains(zombie1eat) && zombie1eat.Eat( this )) || (zombie1eatR != null && getNeighbours(getImage().getWidth()/ 2 , false , Zombie1R. class ).contains(zombie1eatR) && zombie1eatR.Eat( this )) || (zombie2eat != null && getNeighbours(getImage().getWidth() , false , Zombie2. class ).contains(zombie2eat) && zombie2eat.Eat( this )) || (zombie2eatR != null && getNeighbours(getImage().getWidth() , false , Zombie2R. class ).contains(zombie2eatR) && zombie2eatR.Eat( this ))) { health--; getWorld().removeObject(fullbar); getWorld().addObject(halfbar, getWorld().getWidth()/ 3 , getWorld().getHeight()/ 3 ); } if (health== 60 ) { if (direction== 1 ) { setImage( "Wraith_01_Dying_000.png" ); getImage().scale( 107 , 160 ); getWorld().addObject(halfbar, getWorld().getWidth()/ 3 , getWorld().getHeight()/ 3 ); } else { setImage( "Wraith_01_Dying_000.png" ); getImage().scale( 107 , 160 ); getImage().mirrorHorizontally(); getWorld().addObject(halfbar, getWorld().getWidth()/ 3 , getWorld().getHeight()/ 3 ); } return ; } if (health== 30 ) { if (direction== 1 ) { setImage( "Wraith_01_Dying_000.png" ); getImage().scale( 107 , 160 ); } else { setImage( "Wraith_01_Dying_000.png" ); getImage().scale( 107 , 160 ); getImage().mirrorHorizontally(); } return ; } if (health== 0 ) { if (direction== 1 ) { setImage( "Wraith_01_Dying_014.png" ); getImage().scale( 260 , 210 ); } else { setImage( "Wraith_01_Dying_014.png" ); getImage().scale( 260 , 210 ); getImage().mirrorHorizontally(); } getWorld().showText( "You Lose! - You lasted " +(gameTime/ 60 ) + " seconds" , getWorld().getWidth()/ 2 , getWorld().getHeight()/ 2 ); Greenfoot.stop(); return ; } } |