this is the error i get when I try to run my game, I have good and bad knights each have to actors to switch between to give them an animated look
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Knight1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Knight1 extends Actor
{private int Walk = (6);
/**
* Act - do whatever the Knight1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(1);
Walk -- ;
if(Walk == 0)
{
getWorld().addObject(new Knight2(), getX(), getY());
getWorld().removeObject(this);
}
Actor BadKNight2 = (new BadKNight2());
if (BadKNight2 != null)
{
World world;
world = getWorld();
world.removeObject(BadKNight2);
return;
}
Actor BadKnight1 = (new BadKnight1());
if (BadKnight1 != null)
{
World world;
world = getWorld();
world.removeObject(BadKnight1);
return;
}
}
}
This is my code for one of my knights when walk = 0 that is when the image switches over to Knight two when this happens the illusion of walking is seen. I think that the problem has to do with the actors (like Knight1 and Knight2) Switching out all the time and it does not work with the worldremoveObject method but I am not sure. Any suggestions?

