xiandie/scene/entity/audio/bgm_control.gd
2025-06-27 11:43:23 +08:00

25 lines
702 B
GDScript

class_name BgmControl extends Node
@export_enum("start", "stop") var mode = "start"
@export var bgm_title = ""
@export var bgm_stream: AudioStream
@export var db := 0.0
@export var stop_ease_duration := 3.0
func _ready() -> void:
if not bgm_title:
printerr("[BgmControl] no title fond!")
if mode == "stop":
AudioManager.stop_bgm_music(bgm_title, stop_ease_duration)
elif mode == "start":
if not bgm_stream:
printerr("bgm_stream is null, please check the BGM settings.")
return
AudioManager.loop_bgm_music(bgm_title, bgm_stream, db)
func stop():
if bgm_title:
AudioManager.stop_bgm_music(bgm_title, stop_ease_duration)
else:
printerr("[BgmControl] stop err, no title fond!")