bugged-racing/music/MusicPlayer.gd

16 lines
308 B
GDScript
Raw Permalink Normal View History

2021-11-22 19:48:43 +00:00
extends Node
export var main_theme: AudioStream
2021-11-22 20:23:06 +00:00
var current_theme = null
2021-11-22 19:48:43 +00:00
2021-11-22 20:23:06 +00:00
onready var themes = {"main": main_theme}
2021-11-22 19:48:43 +00:00
onready var player: AudioStreamPlayer = $Player
func play_theme(theme: String) -> void:
2021-11-22 20:23:06 +00:00
if theme != current_theme:
player.stream = themes[theme]
player.play()
current_theme = theme