Files
Super-Mario-Bros.-Remastere…/Scripts/Classes/Entities/Items/KeyItem.gd
2025-09-13 16:30:32 +01:00

19 lines
458 B
GDScript

class_name KeyItem
extends Node2D
static var total_collected := 0
const SMOKE_PARTICLE = preload("uid://d08nv4qtfouv1")
func _ready() -> void:
$AnimationPlayer.play("Float")
func collected() -> void:
total_collected += 1
AudioManager.play_sfx("key_collect", global_position)
summon_smoke_particle()
queue_free()
func summon_smoke_particle() -> void:
var node = SMOKE_PARTICLE.instantiate()
node.global_position = global_position
add_sibling(node)