Hey guys, I need help updating my hp bar. I already have the health subclass for actor, but I want to implement it to where if myCharacter actor touches the enemy1 actor, the bar updates and decreases a life.
This is the only code I have for the health.
public class Health extends Actor { GreenfootImage[] hearts = { new GreenfootImage("0hearts.png"), new GreenfootImage("1hearts.png"), new GreenfootImage("2hearts.png"), new GreenfootImage("3hearts.png") }; int health = 3; private void updateImage() { setImage(hearts[health]); } /** * Act - do whatever the Health wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. } public Health() { GreenfootImage image = getImage(); image.scale(image.getWidth() - 25, image.getHeight() - 25); setImage(image); updateImage(); } public void adjustHearts(int adjustmentValue) { health += adjustmentValue; } }