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 ?
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; } }