Пример #1
0
  public void setValues(int health) {
    this.health = health;

    healthNumber.setImage(SmallNumber.getImageComponent(String.valueOf(health)));
    healthNumber.setLocation(23 - healthNumber.getWidth(), 16);

    int healthBarWidth = healthBarMaxWidth * health / healthCap;

    healthBar1.setSize(healthBarWidth, healthBar1.getHeight());
    healthBar2.setSize(healthBarWidth, healthBar2.getHeight());

    repaint();
  }
Пример #2
0
  public PanelHealth() {
    background = new ImageComponent("resources/gui/window/healthDisplayBlue.png");
    healthBar1 = new ImageComponent("resources/gui/window/healthDisplayBar.png");
    healthBar2 = new ImageComponent("resources/gui/window/healthDisplayBar.png");

    healthBarMaxWidth = healthBar1.getWidth();

    healthBar1.setLocation(27 + 1, 19);
    healthBar2.setLocation(27, 19 + 1);

    name = Character.getImageComponent("Lyn");
    name.setLocation(9 + (60 - name.getWidth()) / 2, 3);

    healthNumber = SmallNumber.getImageComponent("16");
    healthNumber.setLocation(23 - healthNumber.getWidth(), 16);

    add(name);
    add(healthNumber);
    add(healthBar1);
    add(healthBar2);
    add(background);

    setLayout(null);
    setOpaque(false);
    setVisible(true);

    setSize(background.getWidth(), background.getHeight());
    setPreferredSize(getSize());
  }