ok so i have a terminal error when my boss dies
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed.
at greenfoot.Actor.failIfNotInWorld(Actor.java:713)
at greenfoot.Actor.isTouching(Actor.java:978)
at Boss.IntersectingBullet(Boss.java:49)
at Boss.act(Boss.java:41)
at greenfoot.core.Simulation.actActor(Simulation.java:567)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:530)
at greenfoot.core.Simulation.runContent(Simulation.java:193)
at greenfoot.core.Simulation.run(Simulation.java:183)
and the code for boss
public class Boss extends EnemyCharacters
{
private GreenfootImage Boss = new GreenfootImage("Boss.png");
private GreenfootImage Boss2 = new GreenfootImage("Boss2.png");
private GreenfootImage BossA1S1= new GreenfootImage("BossA1S1.png");
private GreenfootImage BossA1S2= new GreenfootImage("BossA1S2.png");
private GreenfootImage BossA2S1= new GreenfootImage("BossA2S1.png");
private GreenfootImage BossA2S2= new GreenfootImage("BossA2S2.gif");
private GreenfootImage BossFA1= new GreenfootImage("BossFA1.png");
private GreenfootImage BossFA2= new GreenfootImage("BossFA2.png");
private GreenfootImage BossFF= new GreenfootImage("BossFF.png");
private GreenfootImage BossFFA1S1= new GreenfootImage("BossFFA1S1.png");
private GreenfootImage BossFFA1S2= new GreenfootImage("BossFFA1S2.png");
private GreenfootImage Defeat= new GreenfootImage("BossDefeated.png");
private GreenfootImage Defeat2= new GreenfootImage("BossDefeated2.png");
private int animatecounter;
public int lives = 50;
/**
* Act - do whatever the Boss wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
NormalAnimation();
Attack1Animation();
Attack2Animation();
FA();
FF();
FFA();
Defeat();
Attack2();
FinalAttack();
IntersectingBullet();
}
public void BossHealth()
{
lives--;
}
public void IntersectingBullet()
{
if (isTouching(Bullet.class))
{
removeTouching(Bullet.class);
BossHealth();
}
}
private void NormalAnimation()
{
if (lives == 50){
animatecounter++;
if (animatecounter > 5) {
animatecounter = 0;
if (getImage() == Boss) {
setImage(Boss2);
}
else {
setImage(Boss); }
}
}
}
private void Attack1Animation()
{
if (lives <= 49)
{
animatecounter++;
if (animatecounter > 10) {
animatecounter = 0;
if (getImage() == BossA1S1) {
setImage(BossA1S2);
}
else {
setImage(BossA1S1); }
}
}
}
private void Attack2()
{
if (lives == 40)
{
setImage(BossA2S1);
}
}
private void Attack2Animation()
{
if (lives <= 39)
{
animatecounter++;
if(animatecounter > 10)
{
animatecounter = 0;
if (getImage() == BossA2S1)
{
setImage(BossA2S2);
}
else
{
setImage(BossA2S1);
}
}
}
}
private void FinalAttack()
{
if (lives == 30)
{
setImage(BossFA1);
}
}
private void FA()
{
if (lives <= 29)
{
animatecounter++;
if(animatecounter > 10)
{
animatecounter = 0;
if (getImage() == BossFA1)
{
setImage(BossFA2);
}
else
{
setImage(BossFA1);
}
}
}
}
public void FF()
{
if (lives == 20)
{
setImage(BossFF);
}
}
private void FFA()
{
if (lives == 19)
{
animatecounter++;
if(animatecounter > 10)
{
animatecounter = 0;
if (getImage() == BossFFA1S1)
{
setImage(BossFFA1S2);
}
else
{
setImage(BossFFA1S1);
}
}
}
}
public void Defeat()
{
if (lives == 0)
{
animatecounter++;
if(animatecounter > 5)
{
animatecounter = 0;
if (getImage() == Defeat)
{
setImage(Defeat2);
}
else
{
setImage(Defeat);
}
}
Greenfoot.delay(5);
getWorld().removeObject(this);
}
}
}


