How to create a loading screen

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kyle J144

Hey,

I am relatively new to Godot and I have search for tutorials regarding this, but I am unsuccessful on finding any, but anyway I am look to create a loading screen with with a slideshow and maybe information displayed and a loading symbol, so the player knows the game is loading and while the game is loading then the player can read what the game has to offer with some snippets of the game displayed on the loading screen and a loading symbol at the bottom right hand corner with the loading percentage.

Is this possible? and if so how would I go about implementing this.

Any help appreciated and thanks in advance.

May be a bit far fetched, but did you check the tutorial on background loading? May be the first step towards creating a larger loading screen.

Ertain | 2019-02-26 01:00

Yeah i have had a look at that document, but it is a bit hard to understand, because it does not tell you how to start creating the loading screen, which nodes to use or even which nodes or where to attach the scripts :confused:

Kyle J144 | 2019-02-26 01:15

Yeah I also got error then a black screen when I play the loading screen

andrewtu0182 | 2020-06-15 15:03

:bust_in_silhouette: Reply From: RenenerG

Take a look at background loading from the docs.

With that, you could set up a very simple scene, like this:

Control
    ColorRect
        CenterContainer
            VBoxContainer
                Label
                TextureProgress

These are basic ui nodes. The ColorRect is just extended over the whole screen in black. The CenterContainer centers his childrens. The VBoxContainer alignes his childrens in vertical order. Label just showing the text “Loading…” and TextureProgress shows the actual progress of the background loading, mentioned above.


It could look like this:

title screen


So, how to upgrade the progress bar?
First you need to read and understand the background loading chapter, mentioned above.

Then you could just calculate the progress, similar to the background loading tutorial.
This progress could be passed to a reference of your loading screen, which just calls a method to update your progress bar:

func update_progress(progress : float) -> void: 
    textureProgress.set_value(progress)

I have received an error also how do i add the progress bar because that is not showing up

extends Control

Ref ResourceLoader::load_interactive(String p_path);
Error ResourceInteractiveLoader::poll();

int ResourceInteractiveLoader::get_stage_count() const;
int ResourceInteractiveLoader::get_stage() const;

Ref ResourceInteractiveLoader::get_resource();

var loader
var wait_frames
var time_max = 100
var current_scene

func _ready():
var root = get_tree().get_root()
current_scene = root.get_child(root.get_child_count() -1)

func goto_scene(path):
loader = ResourceLoader.load_interactive(path)
if loader == null:
show_error()
return
set_process(true)

current_scene.queue_free()

get_node("animation").play("loading")

wait_frames = 1

func _process(time):
if loader == null:
set_process(false)
return

if wait_frames >0:
	wait_frames -= 1
	return
	
var t = OS.get_ticks_msec()
while OS.get_ticks_msec() < t + time_max:
	
	var err = loader.poll()
	
	if err == ERR_FILE_EOF:
		var resource = loader.get_resource()
		loader = null
		set_new_scene(resource)
		break
		elif err ==ok:
			update()
		else:
			show_error()
			loader = null
			break

and on that document it tells me to add animation ,but I want it like the image you sent me :confused:

Kyle J144 | 2019-02-26 12:01

I have received an error

What error do you received?

also how do i add the progress bar because that is not showing up

A TextureProgress node needs a texture_progress -texture, which could be added in the inspector tab.

and on that document it tells me to add animation ,but I want it like the image you sent me :confused:

You could also use Tweens instead. Or just set the property value of the TextureProgress.

RenenerG | 2019-02-26 13:38

The error i am receiving is:

0:00:00:0517 - Condition ’ _debug_parse_err_line >= 0 ’ is true. returned: __null

Type:Error
Description:
Time: 0:00:00:0517
C Error: Condition ’ _debug_parse_err_line >= 0 ’ is true. returned: __null
C Source: modules/gdscript/gdscript_editor.cpp:287
C Function: debug_get_stack_level_instance

Loading Screen

And where would i put the values and what values would you recommend

Kyle J144 | 2019-02-26 14:15

Hey, I received the error:

error(22,9)L The method "show_error" isn't declared in the current class

It may be because of an update but I am unsure. Can you help please??

Amateur.game.dev. | 2021-03-15 23:01

:bust_in_silhouette: Reply From: exuin

So - what people need to understand about the background loading tutorial in the documentation is that is still loads everything in the main thread. It just stops between loading scenes to poll the ResourceLoader. So if you can’t divide your game into a bunch of smaller scenes to load, you probably shouldn’t follow that tutorial. Actually, don’t follow the tutorial at all - it’s pretty bad and like half of it is in C++. It’s probably better to use multiple threads instead. Unfortunately you can’t have load progress and multiple threads at the same time, but you can just slap a fake loading bar on the screen.

Also note that every thing visual is handled in the main thread so you must use a mutex to update them

Wakatta | 2021-03-08 18:23