Untitled
unknown
plain_text
a month ago
1.7 kB
4
Indexable
Never
extends Node2D @export_file("*.tscn") var next_scene_path:String var progress = [] var text:String= "Chargement 000%" var startedLoading = false var loadingDone = false var animationPlayer:AnimationPlayer # Called when the node enters the scene tree for the first time. func _ready(): animationPlayer = $AnimationPlayer pass # Replace with function body. func change_scene(): get_tree().change_scene_to_packed( ResourceLoader.load_threaded_get(next_scene_path) ) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if (Input.is_action_just_pressed("r")): get_tree().reload_current_scene() if ($TimerStartLoading.is_stopped()): if (!startedLoading): ResourceLoader.load_threaded_request(next_scene_path,"PackedScene",false) startedLoading=true else: if($RefreshLoad.is_stopped()): $RefreshLoad.start() var scene_load_status = ResourceLoader.load_threaded_get_status(next_scene_path,progress) var pourcent:String = str(floor(progress[0]*100)) print("pourcent=",pourcent) if (pourcent.length()==1): $Label.text[8]= "0" $Label.text[9]= "0" $Label.text[10]= pourcent[0] elif (pourcent.length()==2): $Label.text[8]= "0" $Label.text[9]= pourcent[0] $Label.text[10]= pourcent[1] elif (pourcent.length()==3): $Label.text[8]= pourcent[0] $Label.text[9]= pourcent[1] $Label.text[10]= pourcent[2] if progress[0]>=1: loadingDone = true if loadingDone && animationPlayer.current_animation!="ClosingTransition": #closingTransition calls change_scene() function after turning screen to black animationPlayer.play("ClosingTransition")
Leave a Comment