Added loading screen
This commit is contained in:
31
client/Start.gd
Normal file
31
client/Start.gd
Normal file
@ -0,0 +1,31 @@
|
||||
extends Node
|
||||
|
||||
@export var scene_path: String
|
||||
@export var progress_bar: ProgressBar
|
||||
@export var modulate: CanvasModulate
|
||||
@export var fade_duration: float
|
||||
@export var use_sub_threads: bool
|
||||
|
||||
var progress: Array
|
||||
|
||||
func _ready():
|
||||
ResourceLoader.load_threaded_request(scene_path, "", use_sub_threads)
|
||||
|
||||
func _process(_delta):
|
||||
var status := ResourceLoader.load_threaded_get_status(scene_path, progress)
|
||||
progress_bar.value = progress[0] * 100
|
||||
|
||||
if status == ResourceLoader.THREAD_LOAD_LOADED:
|
||||
add_scene()
|
||||
fade_out()
|
||||
|
||||
func add_scene():
|
||||
var scene := ResourceLoader.load_threaded_get(scene_path)
|
||||
var node := scene.instantiate() as Node
|
||||
get_tree().root.add_child(node)
|
||||
|
||||
func fade_out():
|
||||
progress_bar.hide()
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property(modulate, "color", Color(1.0, 1.0, 1.0, 0), fade_duration)
|
||||
tween.tween_callback(queue_free)
|
Reference in New Issue
Block a user