32 lines
764 B
GDScript
32 lines
764 B
GDScript
extends AudioStreamPlayer
|
|
|
|
@export var audio: Array[AudioStream]
|
|
@export var text: Array[String]
|
|
var last_level = 0
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
|
|
if volume_db != Globals.voice_volume:
|
|
volume_db = Globals.voice_volume
|
|
|
|
if !playing:
|
|
$CanvasLayer/Control/Label.visible = false
|
|
|
|
if LevelLoader.current_index != last_level && !playing:
|
|
if last_level == 0:
|
|
last_level = LevelLoader.current_index
|
|
else:
|
|
last_level += 1
|
|
stream = audio[last_level - 1]
|
|
$CanvasLayer/Control/Label.text = text[last_level - 1]
|
|
play()
|
|
$CanvasLayer/Control/Label.visible = true
|
|
|