Class EnemyHealthDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.enemy.EnemyHealthDisplay
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the entity is created and registered.void
dispose()
Cleans up resources when the entity is destroyed.int
int
void
update()
Updates the position of the enemy's health bar every frame.void
updateEnemyHealthUI
(int health) Updates the enemy's health on the UI.Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
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. -
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. -
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. -
getMaxHealth
public int getMaxHealth() -
getCurrentHealth
public int getCurrentHealth()
-