21 lines
509 B
Java
21 lines
509 B
Java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|
|
|
/**
|
|
* Write a description of class Healthbar here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class Healthbar extends Actor
|
|
{
|
|
public void act()
|
|
{
|
|
draw_health();
|
|
}
|
|
|
|
public void draw_health(){
|
|
Player player = getWorld().getObjects(Player.class).get(0);
|
|
setImage(new GreenfootImage("Health:" + player.health, 24, Color.WHITE, Color.BLACK));
|
|
}
|
|
}
|