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

View File

@@ -0,0 +1,33 @@
extends Node
# Changing scenes is most easily done using the functions `change_scene`
# and `change_scene_to` of the SceneTree. This script demonstrates how to
# change scenes without those helpers.
func goto_scene(path):
# This function will usually be called from a signal callback,
# or some other function from the running scene.
# Deleting the current scene at this point might be
# a bad idea, because it may be inside of a callback or function of it.
# The worst case will be a crash or unexpected behavior.
# The way around this is deferring the load to a later time, when
# it is ensured that no code from the current scene is running:
call_deferred("_deferred_goto_scene", path)
func _deferred_goto_scene(path):
# Immediately free the current scene, there is no risk here.
get_tree().get_current_scene().free()
# Load new scene
var packed_scene = ResourceLoader.load(path)
# Instance the new scene
var instanced_scene = packed_scene.instance()
# Add it to the scene tree, as direct child of root
get_tree().get_root().add_child(instanced_scene)
# Set it as the current scene, only after it has been added to the tree
get_tree().set_current_scene(instanced_scene)

View File

@@ -0,0 +1,36 @@
; 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="Autoload (Singletons)"
run/main_scene="res://scene_a.tscn"
[autoload]
global="res://global.gd"
[display]
window/stretch/mode="2d"
window/stretch/aspect="expand"
[gdnative]
singletons=[ ]
[memory]
multithread/thread_rid_pool_prealloc=60

View File

@@ -0,0 +1,4 @@
extends Panel
func _on_goto_scene_pressed():
get_node("/root/global").goto_scene("res://scene_b.tscn")

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scene_a.gd" type="Script" id=1]
[node name="SceneA" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( 1 )
[node name="Label" type="Label" parent="."]
margin_left = 64.0
margin_top = 48.0
margin_right = 104.0
margin_bottom = 62.0
size_flags_vertical = 0
text = "This is scene A."
[node name="GoToSceneB" type="Button" parent="."]
margin_left = 64.0
margin_top = 128.0
margin_right = 192.0
margin_bottom = 160.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Go to Scene B"
[connection signal="pressed" from="GoToSceneB" to="." method="_on_goto_scene_pressed"]

View File

@@ -0,0 +1,4 @@
extends Panel
func _on_goto_scene_pressed():
get_node("/root/global").goto_scene("res://scene_a.tscn")

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scene_b.gd" type="Script" id=1]
[node name="SceneB" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( 1 )
[node name="Label" type="Label" parent="."]
margin_left = 64.0
margin_top = 48.0
margin_right = 164.0
margin_bottom = 62.0
size_flags_vertical = 0
text = "This is scene B."
[node name="GoToSceneA" type="Button" parent="."]
margin_left = 64.0
margin_top = 128.0
margin_right = 192.0
margin_bottom = 160.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Go to Scene A"
[connection signal="pressed" from="GoToSceneA" to="." method="_on_goto_scene_pressed"]

View File

@@ -0,0 +1,66 @@
extends Control
var thread = null
onready var progress = $progress
var SIMULATED_DELAY_SEC = 1.0
func _thread_load(path):
var ril = ResourceLoader.load_interactive(path)
assert(ril)
var total = ril.get_stage_count()
# Call deferred to configure max load steps
progress.call_deferred("set_max", total)
var res = null
while true: #iterate until we have a resource
# Update progress bar, use call deferred, which routes to main thread
progress.call_deferred("set_value", ril.get_stage())
# Simulate a delay
OS.delay_msec(SIMULATED_DELAY_SEC * 1000.0)
# Poll (does a load step)
var err = ril.poll()
# if OK, then load another one. If EOF, it' s done. Otherwise there was an error.
if err == ERR_FILE_EOF:
# Loading done, fetch resource
res = ril.get_resource()
break
elif err != OK:
# Not OK, there was an error
print("There was an error loading")
break
# Send whathever we did (or not) get
call_deferred("_thread_done", res)
func _thread_done(resource):
assert(resource)
# Always wait for threads to finish, this is required on Windows
thread.wait_to_finish()
#Hide the progress bar
progress.hide()
# Instantiate new scene
var new_scene = resource.instance()
# Free current scene
get_tree().current_scene.free()
get_tree().current_scene = null
# Add new one to root
get_tree().root.add_child(new_scene)
# Set as current scene
get_tree().current_scene = new_scene
progress.visible = false
func load_scene(path):
thread = Thread.new()
thread.start( self, "_thread_load", path)
raise() # show on top
progress.visible = true

View File

@@ -0,0 +1,14 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://background_load.gd" type="Script" id=1]
[node name="bgload" type="Control"]
script = ExtResource( 1 )
[node name="progress" type="ProgressBar" parent="."]
visible = false
margin_left = 7.0
margin_top = 8.0
margin_right = 207.0
margin_bottom = 22.0
step = 1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_babel.jpg-bb6b7c64c260f78ce43012bcac8a1c4e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_babel.jpg"
dest_files=[ "res://.import/painting_babel.jpg-bb6b7c64c260f78ce43012bcac8a1c4e.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_las_meninas.png-158bef53fe63c53626df2020827ea75b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_las_meninas.png"
dest_files=[ "res://.import/painting_las_meninas.png-158bef53fe63c53626df2020827ea75b.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_mona_lisa.jpg-cefdc64dfa49e9ee9566b078597cd552.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_mona_lisa.jpg"
dest_files=[ "res://.import/painting_mona_lisa.jpg-cefdc64dfa49e9ee9566b078597cd552.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_old_guitarist.jpg-f04ba627b38b0def60d96cb6c0bfa12b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_old_guitarist.jpg"
dest_files=[ "res://.import/painting_old_guitarist.jpg-f04ba627b38b0def60d96cb6c0bfa12b.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_parasol.jpg-2864da595fcb4f0e842ba9c49097a056.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_parasol.jpg"
dest_files=[ "res://.import/painting_parasol.jpg-2864da595fcb4f0e842ba9c49097a056.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/painting_the_swing.jpg-1303041ac03cbc85efa4b07ce56efbc4.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://painting_the_swing.jpg"
dest_files=[ "res://.import/painting_the_swing.jpg-1303041ac03cbc85efa4b07ce56efbc4.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=true
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,5 @@
extends Node2D
func _on_switch_pressed():
$CanvasLayer/switch.hide()
background_load.load_scene("res://sculptures.tscn")

View File

@@ -0,0 +1,212 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://paintings.gd" type="Script" id=1]
[ext_resource path="res://painting_parasol.jpg" type="Texture" id=2]
[ext_resource path="res://painting_babel.jpg" type="Texture" id=3]
[ext_resource path="res://painting_mona_lisa.jpg" type="Texture" id=4]
[ext_resource path="res://painting_las_meninas.png" type="Texture" id=5]
[ext_resource path="res://painting_old_guitarist.jpg" type="Texture" id=6]
[ext_resource path="res://painting_the_swing.jpg" type="Texture" id=7]
[sub_resource type="Animation" id=1]
resource_name = "move_around"
length = 4.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("painting_mona_lisa:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 117.659, 173.793 ), Vector2( 164.387, 206.955 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("painting_mona_lisa:rotation_degrees")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("painting_parasol:position")
tracks/2/interp = 2
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 451.448, 256.916 ), Vector2( 483.102, 317.21 ) ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("painting_parasol:rotation_degrees")
tracks/3/interp = 2
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0 ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("painting_the_swing:position")
tracks/4/interp = 2
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 715.927, 181.745 ), Vector2( 661.663, 205.863 ) ]
}
tracks/5/type = "value"
tracks/5/path = NodePath("painting_the_swing:rotation_degrees")
tracks/5/interp = 2
tracks/5/loop_wrap = true
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0 ]
}
tracks/6/type = "value"
tracks/6/path = NodePath("painting_old_guitarist:position")
tracks/6/interp = 2
tracks/6/loop_wrap = true
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 886.982, 185.641 ), Vector2( 901.179, 210.693 ) ]
}
tracks/7/type = "value"
tracks/7/path = NodePath("painting_old_guitarist:rotation_degrees")
tracks/7/interp = 2
tracks/7/loop_wrap = true
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 15.0 ]
}
tracks/8/type = "value"
tracks/8/path = NodePath("painting_babel:position")
tracks/8/interp = 2
tracks/8/loop_wrap = true
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 155.796, 468.287 ), Vector2( 194.21, 444.904 ) ]
}
tracks/9/type = "value"
tracks/9/path = NodePath("painting_babel:rotation_degrees")
tracks/9/interp = 2
tracks/9/loop_wrap = true
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0 ]
}
tracks/10/type = "value"
tracks/10/path = NodePath("painting_las_meninas:position")
tracks/10/interp = 2
tracks/10/loop_wrap = true
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 861.734, 494.059 ), Vector2( 840.022, 470.677 ) ]
}
tracks/11/type = "value"
tracks/11/path = NodePath("painting_las_meninas:rotation_degrees")
tracks/11/interp = 2
tracks/11/loop_wrap = true
tracks/11/imported = false
tracks/11/enabled = true
tracks/11/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0 ]
}
[node name="Node2D" type="Node2D"]
script = ExtResource( 1 )
[node name="painting_parasol" type="Sprite" parent="."]
position = Vector2( 451.448, 256.916 )
scale = Vector2( 0.557998, 0.557998 )
texture = ExtResource( 2 )
[node name="painting_babel" type="Sprite" parent="."]
position = Vector2( 155.796, 468.287 )
scale = Vector2( 0.29005, 0.29005 )
texture = ExtResource( 3 )
[node name="painting_mona_lisa" type="Sprite" parent="."]
position = Vector2( 117.659, 173.793 )
scale = Vector2( 0.696799, 0.696799 )
texture = ExtResource( 4 )
[node name="painting_las_meninas" type="Sprite" parent="."]
position = Vector2( 861.734, 494.059 )
scale = Vector2( 0.348146, 0.348146 )
texture = ExtResource( 5 )
[node name="painting_old_guitarist" type="Sprite" parent="."]
position = Vector2( 886.982, 185.641 )
scale = Vector2( 0.344706, 0.328421 )
texture = ExtResource( 6 )
[node name="painting_the_swing" type="Sprite" parent="."]
position = Vector2( 715.927, 181.745 )
scale = Vector2( 0.286677, 0.286677 )
texture = ExtResource( 7 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "move_around"
anims/move_around = SubResource( 1 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 512, 300 )
current = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="switch" type="Button" parent="CanvasLayer"]
margin_left = 10.0
margin_top = 10.0
margin_right = 156.0
margin_bottom = 30.0
text = "Switch to Sculptures"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="CanvasLayer/switch" to="." method="_on_switch_pressed"]

View File

@@ -0,0 +1,105 @@
; 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="Background Thread Loading Demo"
run/main_scene="res://paintings.tscn"
[autoload]
background_load="*res://background_load.tscn"
[display]
window/stretch/mode="2d"
window/stretch/aspect="expand"
[input]
ui_accept={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_cancel={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_focus_next={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null)
]
}
ui_focus_prev={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null)
]
}
ui_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_page_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777235,"unicode":0,"echo":false,"script":null)
]
}
ui_page_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777236,"unicode":0,"echo":false,"script":null)
]
}
ui_home={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777229,"unicode":0,"echo":false,"script":null)
]
}
ui_end={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777230,"unicode":0,"echo":false,"script":null)
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_david.jpg-48aeb7cb164d32e6f17209e6764b659c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_david.jpg"
dest_files=[ "res://.import/sculpture_david.jpg-48aeb7cb164d32e6f17209e6764b659c.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_fountain.jpg-dac3819d7eb39b78d36e9f6504d09bc6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_fountain.jpg"
dest_files=[ "res://.import/sculpture_fountain.jpg-dac3819d7eb39b78d36e9f6504d09bc6.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_four_parts_of_earth.jpg-6d7b17284103f155af8220c6e7c0afb3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_four_parts_of_earth.jpg"
dest_files=[ "res://.import/sculpture_four_parts_of_earth.jpg-6d7b17284103f155af8220c6e7c0afb3.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_lincoln.jpg-2309a3ef73573c72052204394b916eef.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_lincoln.jpg"
dest_files=[ "res://.import/sculpture_lincoln.jpg-2309a3ef73573c72052204394b916eef.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_thinker.jpg-d13623267c5f848cecaa2bb8bb609f24.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_thinker.jpg"
dest_files=[ "res://.import/sculpture_thinker.jpg-d13623267c5f848cecaa2bb8bb609f24.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sculpture_venus.png-ce0240c8ebb6a0aae05e92456d21d8f3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sculpture_venus.png"
dest_files=[ "res://.import/sculpture_venus.png-ce0240c8ebb6a0aae05e92456d21d8f3.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=true
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,5 @@
extends Node2D
func _on_switch_pressed():
$CanvasLayer/switch.hide()
background_load.load_scene("res://paintings.tscn")

View File

@@ -0,0 +1,140 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://sculptures.gd" type="Script" id=1]
[ext_resource path="res://sculpture_fountain.jpg" type="Texture" id=2]
[ext_resource path="res://sculpture_four_parts_of_earth.jpg" type="Texture" id=3]
[ext_resource path="res://sculpture_david.jpg" type="Texture" id=4]
[ext_resource path="res://sculpture_lincoln.jpg" type="Texture" id=5]
[ext_resource path="res://sculpture_thinker.jpg" type="Texture" id=6]
[ext_resource path="res://sculpture_venus.png" type="Texture" id=7]
[sub_resource type="Animation" id=1]
resource_name = "colorcycle"
length = 8.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("sculpture_four_parts_of_earth:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 0.827451, 0.25098, 0.25098, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("sculpture_fountain:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("sculpture_lincoln:modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 4.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 0.32549, 0.407843, 0.862745, 1 ) ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("sculpture_david:modulate")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0, 4.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 0.180392, 0.866667, 0.137255, 1 ) ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("sculpture_thinker:modulate")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 0, 4.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 0.898039, 0, 1, 1 ) ]
}
tracks/5/type = "value"
tracks/5/path = NodePath("sculpture_venus:modulate")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/keys = {
"times": PoolRealArray( 0, 4.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 0, 0, 0, 1 ) ]
}
[node name="Node2D" type="Node2D"]
script = ExtResource( 1 )
[node name="sculpture_fountain" type="Sprite" parent="."]
position = Vector2( 152.971, 513.499 )
scale = Vector2( 0.191615, 0.191615 )
texture = ExtResource( 2 )
[node name="sculpture_four_parts_of_earth" type="Sprite" parent="."]
position = Vector2( 480.743, 588.027 )
scale = Vector2( 0.198693, 0.198693 )
texture = ExtResource( 3 )
[node name="sculpture_david" type="Sprite" parent="."]
position = Vector2( 567.784, 196.577 )
scale = Vector2( 0.447348, 0.447348 )
texture = ExtResource( 4 )
[node name="sculpture_lincoln" type="Sprite" parent="."]
position = Vector2( 211.852, 203.688 )
scale = Vector2( 0.386179, 0.378971 )
texture = ExtResource( 5 )
[node name="sculpture_thinker" type="Sprite" parent="."]
position = Vector2( 854.336, 202.363 )
scale = Vector2( 0.182302, 0.182302 )
texture = ExtResource( 6 )
[node name="sculpture_venus" type="Sprite" parent="."]
position = Vector2( 848.731, 495.153 )
scale = Vector2( 0.402249, 0.402249 )
texture = ExtResource( 7 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "colorcycle"
anims/colorcycle = SubResource( 1 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 512, 300 )
current = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="switch" type="Button" parent="CanvasLayer"]
margin_left = 10.0
margin_top = 10.0
margin_right = 142.0
margin_bottom = 30.0
text = "Switch to Paintings"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="CanvasLayer/switch" to="." method="_on_switch_pressed"]

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="Scene Changer"
run/main_scene="res://scene_a.tscn"
[debug]
gdscript/warnings/return_value_discarded=false
[display]
window/stretch/mode="2d"
window/stretch/aspect="expand"
[gdnative]
singletons=[ ]

View File

@@ -0,0 +1,4 @@
extends Panel
func _on_goto_scene_pressed():
get_tree().change_scene("res://scene_b.tscn")

View File

@@ -0,0 +1,31 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scene_a.gd" type="Script" id=1]
[node name="scene_a" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="label" type="Label" parent="."]
margin_left = 64.0
margin_top = 48.0
margin_right = 104.0
margin_bottom = 62.0
size_flags_vertical = 0
text = "This is scene A."
[node name="goto_scene" type="Button" parent="."]
margin_left = 64.0
margin_top = 128.0
margin_right = 192.0
margin_bottom = 160.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Go to Scene B"
[connection signal="pressed" from="goto_scene" to="." method="_on_goto_scene_pressed"]

View File

@@ -0,0 +1,4 @@
extends Panel
func _on_goto_scene_pressed():
get_tree().change_scene("res://scene_a.tscn")

View File

@@ -0,0 +1,62 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scene_b.gd" type="Script" id=1]
[node name="scene_b" type="Panel"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( 1 )
[node name="label" type="Label" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 64.0
margin_top = 48.0
margin_right = 164.0
margin_bottom = 62.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
size_flags_horizontal = 1
size_flags_vertical = 0
text = "This is scene B."
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="goto_scene" type="Button" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 64.0
margin_top = 128.0
margin_right = 192.0
margin_bottom = 160.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Go to Scene A"
flat = false
[connection signal="pressed" from="goto_scene" to="." method="_on_goto_scene_pressed"]

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"]