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.

test_hud.gd 578 B

4 jaren geleden
12345678910111213141516171819202122
  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")