I am having trouble with the label class, I have a label and my "bullet" is supposed to make +1 label appear when ever it hits an enemy but the bullet does not appear anymore. Here is my code for the "bullet":
public void seesJam()//Is it touching the jamBread?
{
if ( canSee(jamBread.class) )//If so, eat the jamBread, place a +1 label, and leave.
{
eat(jamBread.class);
getWorld().addObject (new Label("+1"), getX(), getY());
getWorld().removeObject(this);
}
}
(Note: JamBread is the enemy class)
and here is the label code:
public Label(String text)
{
GreenfootImage img = new GreenfootImage (text.length()*20, 30);
img.drawString (text, 4, 40);
setImage (img);
}
