hello nobody knows how to make a life bar that is spent slowly.
if anyone knows please send me the code
public class HealthBar extends Actor { private int health = 100; public void getHealth() { return health; } public void setHealth(int health) { this.health = health; } }
// Create an image with a specified width and height (the image is transparent by default) GreenfootImage image = new GreenfootImage(102, 12); // Set the color for subsequent operations image.setColor(Color.RED); // Use predefined constants or custom rgb values image.setColor(new Color(50, 100, 150); // Draws the outline of a rectangle with top left at coordinates 0/0 and a size of 102x12 pixels image.drawRect(0, 0, 101, 11); // Fills a rectangle with the top left at coordinates 1/1 and a size of 100x10 pixels image.fillRect(1, 1, 99, 9); // Set the image of the current actor to the specified image setImage(image);