예제 #1
0
파일: PanelHealth.java 프로젝트: peed/FEP
  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());
  }
예제 #2
0
파일: PanelHealth.java 프로젝트: peed/FEP
  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();
  }