Fügt Leben zum Spieler, ein HealthItem und eine Healthbar hinzu.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user