예제 #1
0
  public MilitaryBase(ResourceManager res) {
    maxHealth = 100f;
    health = maxHealth;
    point = Vector2.Zero;
    radius = 450f;

    healthbar = new GameObject(res.healthbar);
    foreground = new GameObject(res.healthbarforeground);
    healthbarbg = new GameObject(res.healthbarbg);

    Vector2 p = new Vector2((MyGame.WIDTH - foreground.getWidth()) / 2, 10);
    foreground.setPos(p);
    healthbar.setPos(new Vector2(p.x, p.y));
    healthbarbg.setPos(p);
    healthbar.setOrigin(new Vector2(0, 0));

    fullWidth = healthbar.getWidth();
  }
예제 #2
0
 public void render(SpriteBatch batch) {
   healthbarbg.render(batch);
   healthbar.render(batch);
   foreground.render(batch);
 }
예제 #3
0
 public void takeDamage(float damage) {
   health -= damage;
   healthbar.setSource(new Rectangle(0, 0, fullWidth * health / maxHealth, healthbar.getHeight()));
 }