KeyItem.gd 458 B

123456789101112131415161718
  1. class_name KeyItem
  2. extends Node2D
  3. static var total_collected := 0
  4. const SMOKE_PARTICLE = preload("uid://d08nv4qtfouv1")
  5. func _ready() -> void:
  6. $AnimationPlayer.play("Float")
  7. func collected() -> void:
  8. total_collected += 1
  9. AudioManager.play_sfx("key_collect", global_position)
  10. summon_smoke_particle()
  11. queue_free()
  12. func summon_smoke_particle() -> void:
  13. var node = SMOKE_PARTICLE.instantiate()
  14. node.global_position = global_position
  15. add_sibling(node)