@tool class_name Sfx2D extends AudioStreamPlayer2D @export var loop := false func _ready() -> void: bus = &"game_sfx" finished.connect(_on_finished) func _on_finished() -> void: if loop: play() # queue free 导致 sfx 无法播放,使用全局声源 func global_play() -> void: if stream: AudioManager.play_sfx(stream) # 注意:会导致 volume db 变化 func easing_kill(duration: float = 2.0) -> void: # stop with easing if playing: var tween = create_tween() tween.tween_property(self, "volume_db", -80.0, duration) tween.tween_callback(stop)