Move loading demos to their own folder

This commit is contained in:
Aaron Franke
2020-01-28 14:19:42 -05:00
parent c6922db2a1
commit 04d86775da
47 changed files with 13 additions and 17 deletions

BIN
loading/threads/mona.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/mona.png-a5ce9963ac8c7ef765aeb0f5428366a9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://mona.png"
dest_files=[ "res://.import/mona.png-a5ce9963ac8c7ef765aeb0f5428366a9.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -0,0 +1,32 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Loading in a Thread"
run/main_scene="res://thread.tscn"
[display]
window/stretch/mode="2d"
window/stretch/aspect="expand"
[gdnative]
singletons=[ ]
[memory]
multithread/thread_rid_pool_prealloc=60

28
loading/threads/thread.gd Normal file
View File

@@ -0,0 +1,28 @@
extends Node2D
var thread = Thread.new()
# This function runs in a thread!
# Threads always take one userdata argument
func _bg_load(path):
print("THREAD FUNC!")
# Load the resource
var tex = ResourceLoader.load(path)
# Call _bg_load_done on main thread
call_deferred("_bg_load_done")
return tex # return it
func _bg_load_done():
# Wait for the thread to complete, get the returned value
var tex = thread.wait_to_finish()
# Set to the sprite
get_node("Sprite").set_texture(tex)
func _on_load_pressed():
if thread.is_active():
# Already working
return
print("START THREAD!")
thread.start(self, "_bg_load", "res://mona.png")

View File

@@ -0,0 +1,26 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://thread.gd" type="Script" id=1]
[node name="Thread" type="Node2D"]
script = ExtResource( 1 )
[node name="Load" type="Button" parent="."]
margin_left = 432.0
margin_top = 82.0
margin_right = 560.0
margin_bottom = 114.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Load in Thread"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 494, 336 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 512, 300 )
current = true
[connection signal="pressed" from="Load" to="." method="_on_load_pressed"]