Class EnemyHealthDisplay

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.enemy.EnemyHealthDisplay

public class EnemyHealthDisplay extends Component
  • Field Details

    • stage

      protected com.badlogic.gdx.scenes.scene2d.Stage stage
  • Constructor Details

    • EnemyHealthDisplay

      public EnemyHealthDisplay()
    • EnemyHealthDisplay

      public EnemyHealthDisplay(float offsetY)
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • updateEnemyHealthUI

      public void updateEnemyHealthUI(int health)
      Updates the enemy's health on the UI. Also update private variable currentHealth for testing purpose.
      Parameters:
      health - enemy health
    • update

      public void update()
      Updates the position of the enemy's health bar every frame. Converts the entity's world coordinates into stage coordinates and repositions the health bar above the enemy. Skips update if the entity or health bar is missing.
      Overrides:
      update in class Component
    • dispose

      public void dispose()
      Cleans up resources when the entity is destroyed. Removes the health bar from the stage to prevent it from lingering after the enemy is removed.
      Overrides:
      dispose in class Component
    • getMaxHealth

      public int getMaxHealth()
    • getCurrentHealth

      public int getCurrentHealth()