NumberPanel.gd 413 B

12345678910111213141516171819202122232425262728293031
  1. tool
  2. class_name NumberPanel
  3. extends Panel
  4. export(String) var title = "Counter"
  5. var counter = 0
  6. onready var label = $Label
  7. onready var counter_label = $CounterLabel
  8. func _ready() -> void:
  9. label.text = title
  10. func increase_counter() -> void:
  11. counter += 1
  12. _refresh_label()
  13. func reset_counter() -> void:
  14. counter = 0
  15. _refresh_label()
  16. func _refresh_label() -> void:
  17. counter_label.text = str(counter)