extends Area2D

@onready var coin_sound = $CoinSound
@onready var sprite = $Sprite2D

func _ready():
	body_entered.connect(_on_body_entered)

func _on_body_entered(body):
	if body is Player:
		sprite.hide()
		coin_sound.play()
		
		# Notify world
		get_tree().current_scene.star_collected()
		
		await coin_sound.finished
		queue_free()
