coins_counter.gd 335 B

12345678910111213141516
  1. class_name CoinsCounter extends Panel
  2. var _coins_collected: int = 0
  3. @onready var _coins_label := $Label as Label
  4. func _ready() -> void:
  5. _coins_label.set_text(str(_coins_collected))
  6. ($AnimatedSprite2D as AnimatedSprite2D).play()
  7. func collect_coin() -> void:
  8. _coins_collected += 1
  9. _coins_label.set_text(str(_coins_collected))