Hi,
No matter how I rearrange the code, I get the same error message. I can't seem to remove the fireball whenever it intersects with other object, and also make it disappear when it reaches the right edge of the world. Is there any way to fix this problem? My code is shown below.
public class Fireball extends Actor
{
private static final int SPEED=7;
/**
* Act - do whatever the Fireball wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(SPEED);
Actor goomba = getOneIntersectingObject(Goomba.class);
if(goomba!=null) {
getWorld().addObject(new Explosion(),getX(),getY());
getWorld().removeObject(this);
}
Blocks rock = (Blocks)getOneIntersectingObject(Blocks.class);
if(rock!=null) {
rock.explode();
getWorld().removeObject(rock);
getWorld().removeObject(this);
}
else{
if(getX()>getWorld().getWidth()-3) {
getWorld().removeObject(this);
}
}
}