MacIcyEngine

GDScript ui_collectible_counter

Oct 31st, 2024 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Control
  2.  
  3. @onready var count_label: Label = %CountLabel
  4.  
  5. var collectible_count: int = 0
  6.  
  7. func _enter_tree() -> void:
  8.     EventHandler.on_collected.connect(increase_collectible_count)
  9.  
  10. func _exit_tree() -> void:
  11.     EventHandler.on_collected.disconnect(increase_collectible_count)
  12.  
  13. func increase_collectible_count() -> void:
  14.     collectible_count += 1
  15.     count_label.text = str(collectible_count)
  16.  
Advertisement
Add Comment
Please, Sign In to add comment