|
|
|
|
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:
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
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
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
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