Hi, I am currently making a game right now which involves animals eating each other. I am quite new to Greenfoot. So I have added a health bar which has 5 lives. I want to add a health pack which my animal can go 'touch' and it will give them 1 extra life (Give back one of the lives). Help would be appreciated. This is the code for the healthbar.
public HealthBar()
{
Check();
}
public void act()
{
Check();
}
public void Check()
{
setImage(new GreenfootImage(healthBarWidth +2, healthBarHeight + 2));
GreenfootImage myImage = getImage();
myImage.setColor(Color.BLACK);
myImage.drawRect(0, 0, healthBarWidth + 1, healthBarHeight + 1);
myImage.setColor(Color.BLUE);
myImage.fillRect(1, 1, health*pixelsperHealthPoint, healthBarHeight);
}
public void loseHealth()
{
health--;
}

