I try to shoot a bullet but it freezes the game and gives me an error, I encountered this problem before where it would give an error after the target had been hit but now it won't even fire. This is my "note" (bullet) code
public class Note extends Player
{
int direction,speed;
/**
* Act - do whatever the Note wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
speed=-5;
setRotation(direction);
move(speed);
ifAtEdge();
hitTree();
destroy();
}
public void ifAtEdge()
{
if (atWorldEdge() == true)
{
getWorld().removeObject(this);
}
}
public boolean atWorldEdge()
{
if (getX() == 0) {
return true;
} else {
return false;
}
}
public void hitTree()
{
if (isTouching(Shrub.class))
{
getWorld().removeObject(this);
}
}
public void destroy()
{
if(getOneIntersectingObject(EvilSpirit.class) != null)
{
getWorld().removeObject(getOneIntersectingObject(EvilSpirit.class));
getWorld().removeObject(this);
}
}
}
Please Help!
