You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
578 B

  1. extends Control
  2. export var healthBar_path : NodePath
  3. onready var healthBar = get_node(healthBar_path)
  4. export var goldText_path : NodePath
  5. onready var goldText = get_node(goldText_path)
  6. # called when we take damage
  7. func update_health_bar (curHp, maxHp):
  8. fetch_components()
  9. healthBar.value = (100 / maxHp) * curHp
  10. # called when our gold changes
  11. func update_gold_text (gold):
  12. fetch_components()
  13. goldText.text = "Gold: " + str(gold)
  14. func fetch_components():
  15. if healthBar == null:
  16. healthBar = get_node("HealthBar")
  17. if goldText == null:
  18. goldText = get_node("GoldText")