diff --git a/loading/README.md b/loading/README.md index 154713aa..1c3b396f 100644 --- a/loading/README.md +++ b/loading/README.md @@ -4,4 +4,4 @@ These demos demonstrate various ways to load scenes and other data. Languages: All are GDScript -Renderers: All are GLES 2 +Renderers: All are Mobile diff --git a/loading/autoload/README.md b/loading/autoload/README.md index 27777c94..fe5840bf 100644 --- a/loading/autoload/README.md +++ b/loading/autoload/README.md @@ -4,7 +4,7 @@ This demo shows how to use autoloads to change between scenes. Language: GDScript -Renderer: Vulkan Mobile +Renderer: Mobile Check out this demo on the asset library: https://godotengine.org/asset-library/asset/529 diff --git a/loading/autoload/global.gd b/loading/autoload/global.gd index bc7b890e..a2b6b8be 100644 --- a/loading/autoload/global.gd +++ b/loading/autoload/global.gd @@ -1,10 +1,10 @@ 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 +# Changing scenes is most easily done using the functions change_scene_to_file +# and change_scene_to_packed of the SceneTree. This script demonstrates how to # change scenes without those helpers. -func goto_scene(path): + +func goto_scene(path: String): # 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 @@ -13,21 +13,20 @@ func goto_scene(path): # 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) + _deferred_goto_scene.call_deferred(path) -func _deferred_goto_scene(path): - # Immediately free the current scene, there is no risk here. - get_tree().get_current_scene().free() +func _deferred_goto_scene(path: String): + # Immediately free the current scene. There is no risk here because the + # call to this method is already deferred. + get_tree().current_scene.free() - # Load new scene - var packed_scene = ResourceLoader.load(path) + var packed_scene := ResourceLoader.load(path) as PackedScene - # Instance the new scene - var instanced_scene = packed_scene.instantiate() + var instanced_scene := packed_scene.instantiate() # Add it to the scene tree, as direct child of root - get_tree().get_root().add_child(instanced_scene) + get_tree().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) + get_tree().current_scene = instanced_scene diff --git a/loading/autoload/project.godot b/loading/autoload/project.godot index a55b1ac4..342d7601 100644 --- a/loading/autoload/project.godot +++ b/loading/autoload/project.godot @@ -14,20 +14,16 @@ config/name="Autoload (Singletons)" config/description="This demo shows how to use autoloads to change between scenes." run/main_scene="res://scene_a.tscn" config/features=PackedStringArray("4.0") +run/low_processor_mode=true [autoload] -global="res://global.gd" +global="*res://global.gd" [display] -window/stretch/mode="canvas_items" -window/stretch/aspect="expand" - -[gdnative] - -singletons=[] +window/vsync/vsync_mode=0 [rendering] -vulkan/rendering/back_end=1 +renderer/rendering_method="mobile" diff --git a/loading/autoload/scene_a.gd b/loading/autoload/scene_a.gd index e1191ebc..233ff509 100644 --- a/loading/autoload/scene_a.gd +++ b/loading/autoload/scene_a.gd @@ -1,4 +1,5 @@ extends Panel + func _on_goto_scene_pressed(): - get_node(^"/root/global").goto_scene("res://scene_b.tscn") + global.goto_scene("res://scene_b.tscn") diff --git a/loading/autoload/scene_a.tscn b/loading/autoload/scene_a.tscn index a94baa9f..902afa35 100644 --- a/loading/autoload/scene_a.tscn +++ b/loading/autoload/scene_a.tscn @@ -1,15 +1,19 @@ -[gd_scene load_steps=2 format=3 uid="uid://bh2ylkcsgejgy"] +[gd_scene load_steps=2 format=3 uid="uid://6xgdg1bmya7c"] [ext_resource type="Script" path="res://scene_a.gd" id="1"] [node name="SceneA" type="Panel"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 2 size_flags_vertical = 2 -script = ExtResource( "1" ) +script = ExtResource("1") [node name="Label" type="Label" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 48.0 offset_right = 104.0 @@ -18,6 +22,7 @@ size_flags_vertical = 0 text = "This is scene A." [node name="GoToSceneB" type="Button" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 128.0 offset_right = 192.0 diff --git a/loading/autoload/scene_b.gd b/loading/autoload/scene_b.gd index dd6be253..62f33d35 100644 --- a/loading/autoload/scene_b.gd +++ b/loading/autoload/scene_b.gd @@ -1,4 +1,5 @@ extends Panel + func _on_goto_scene_pressed(): - get_node(^"/root/global").goto_scene("res://scene_a.tscn") + global.goto_scene("res://scene_a.tscn") diff --git a/loading/autoload/scene_b.tscn b/loading/autoload/scene_b.tscn index d34d9445..62c1f2a9 100644 --- a/loading/autoload/scene_b.tscn +++ b/loading/autoload/scene_b.tscn @@ -1,18 +1,19 @@ -[gd_scene load_steps=2 format=3 uid="uid://pt77vxjf3uwe"] +[gd_scene load_steps=2 format=3 uid="uid://cmu1caqo7k7wy"] [ext_resource type="Script" path="res://scene_b.gd" id="1"] [node name="SceneB" type="Panel"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 2 size_flags_vertical = 2 -script = ExtResource( "1" ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("1") [node name="Label" type="Label" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 48.0 offset_right = 164.0 @@ -21,6 +22,7 @@ size_flags_vertical = 0 text = "This is scene B." [node name="GoToSceneA" type="Button" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 128.0 offset_right = 192.0 diff --git a/loading/autoload/screenshots/autoload.png b/loading/autoload/screenshots/autoload.png index addb2500..c9256082 100644 Binary files a/loading/autoload/screenshots/autoload.png and b/loading/autoload/screenshots/autoload.png differ diff --git a/loading/background_load/README.md b/loading/background_load/README.md deleted file mode 100644 index d755f6b5..00000000 --- a/loading/background_load/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Background Load - -This is a demo showing how to use the `load_interactive()` method of -[`ResourceLoader`](https://docs.godotengine.org/en/latest/classes/class_resourceloader.html) -to load large scenes in the background with a progress bar. - -Language: GDScript - -Renderer: GLES 2 - -Check out this demo on the asset library: https://godotengine.org/asset-library/asset/530 - -## Screenshots - -![Screenshot](screenshots/paintings.png) diff --git a/loading/background_load/background_load.gd b/loading/background_load/background_load.gd deleted file mode 100644 index fb78209a..00000000 --- a/loading/background_load/background_load.gd +++ /dev/null @@ -1,64 +0,0 @@ -extends Control - -const SIMULATED_DELAY_SEC = 0.1 - -var thread = null - -@onready var progress = $Progress - -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(int(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 did 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.instantiate() - # 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 diff --git a/loading/background_load/background_load.tscn b/loading/background_load/background_load.tscn deleted file mode 100644 index 2ffda64d..00000000 --- a/loading/background_load/background_load.tscn +++ /dev/null @@ -1,17 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://background_load.gd" type="Script" id=1] - -[node name="BackgroundLoad" type="Control"] -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Progress" type="ProgressBar" parent="."] -visible = false -offset_left = 7.0 -offset_top = 8.0 -offset_right = 207.0 -offset_bottom = 22.0 -step = 1.0 diff --git a/loading/background_load/paintings.gd b/loading/background_load/paintings.gd deleted file mode 100644 index 74a59167..00000000 --- a/loading/background_load/paintings.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Node2D - -func _on_switch_pressed(): - $CanvasLayer/Switch.hide() - background_load.load_scene("res://sculptures.tscn") diff --git a/loading/background_load/paintings.tscn b/loading/background_load/paintings.tscn deleted file mode 100644 index 98346ec2..00000000 --- a/loading/background_load/paintings.tscn +++ /dev/null @@ -1,213 +0,0 @@ -[gd_scene load_steps=9 format=2] - -[ext_resource path="res://paintings.gd" type="Script" id=1] -[ext_resource path="res://paintings/painting_babel.jpg" type="Texture2D" id=2] -[ext_resource path="res://paintings/painting_las_meninas.png" type="Texture2D" id=3] -[ext_resource path="res://paintings/painting_mona_lisa.jpg" type="Texture2D" id=4] -[ext_resource path="res://paintings/painting_old_guitarist.jpg" type="Texture2D" id=5] -[ext_resource path="res://paintings/painting_parasol.jpg" type="Texture2D" id=6] -[ext_resource path="res://paintings/painting_the_swing.jpg" type="Texture2D" 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("MonaLisa:position") -tracks/0/interp = 2 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(117.659, 173.793), Vector2(164.387, 206.955)] -} -tracks/1/type = "value" -tracks/1/path = NodePath("MonaLisa:rotation_degrees") -tracks/1/interp = 2 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 0.0] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Parasol:position") -tracks/2/interp = 2 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(451.448, 256.916), Vector2(483.102, 317.21)] -} -tracks/3/type = "value" -tracks/3/path = NodePath("Parasol:rotation_degrees") -tracks/3/interp = 2 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 0.0] -} -tracks/4/type = "value" -tracks/4/path = NodePath("TheSwing:position") -tracks/4/interp = 2 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(715.927, 181.745), Vector2(661.663, 205.863)] -} -tracks/5/type = "value" -tracks/5/path = NodePath("TheSwing:rotation_degrees") -tracks/5/interp = 2 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 0.0] -} -tracks/6/type = "value" -tracks/6/path = NodePath("OldGuitarist:position") -tracks/6/interp = 2 -tracks/6/loop_wrap = true -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(886.982, 185.641), Vector2(901.179, 210.693)] -} -tracks/7/type = "value" -tracks/7/path = NodePath("OldGuitarist:rotation_degrees") -tracks/7/interp = 2 -tracks/7/loop_wrap = true -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 15.0] -} -tracks/8/type = "value" -tracks/8/path = NodePath("Babel:position") -tracks/8/interp = 2 -tracks/8/loop_wrap = true -tracks/8/imported = false -tracks/8/enabled = true -tracks/8/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(155.796, 468.287), Vector2(194.21, 444.904)] -} -tracks/9/type = "value" -tracks/9/path = NodePath("Babel:rotation_degrees") -tracks/9/interp = 2 -tracks/9/loop_wrap = true -tracks/9/imported = false -tracks/9/enabled = true -tracks/9/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 0.0] -} -tracks/10/type = "value" -tracks/10/path = NodePath("LasMeninas:position") -tracks/10/interp = 2 -tracks/10/loop_wrap = true -tracks/10/imported = false -tracks/10/enabled = true -tracks/10/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(861.734, 494.059), Vector2(840.022, 470.677)] -} -tracks/11/type = "value" -tracks/11/path = NodePath("LasMeninas:rotation_degrees") -tracks/11/interp = 2 -tracks/11/loop_wrap = true -tracks/11/imported = false -tracks/11/enabled = true -tracks/11/keys = { -"times": PackedFloat32Array(0, 2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 0.0] -} - -[node name="Paintings" type="Node2D"] -script = ExtResource( 1 ) - -[node name="Babel" type="Sprite2D" parent="."] -position = Vector2(155.796, 468.287) -scale = Vector2(0.29005, 0.29005) -texture = ExtResource( 2 ) - -[node name="LasMeninas" type="Sprite2D" parent="."] -position = Vector2(861.734, 494.059) -scale = Vector2(0.348146, 0.348146) -texture = ExtResource( 3 ) - -[node name="MonaLisa" type="Sprite2D" parent="."] -position = Vector2(117.659, 173.793) -scale = Vector2(0.696799, 0.696799) -texture = ExtResource( 4 ) - -[node name="OldGuitarist" type="Sprite2D" parent="."] -position = Vector2(886.982, 185.641) -scale = Vector2(0.344706, 0.328421) -texture = ExtResource( 5 ) - -[node name="Parasol" type="Sprite2D" parent="."] -position = Vector2(451.448, 256.916) -scale = Vector2(0.557998, 0.557998) -texture = ExtResource( 6 ) - -[node name="TheSwing" type="Sprite2D" 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"] -offset_left = 10.0 -offset_top = 10.0 -offset_right = 156.0 -offset_bottom = 30.0 -text = "Switch to Sculptures" -__meta__ = { -"_edit_use_anchors_": false -} - -[connection signal="pressed" from="CanvasLayer/Switch" to="." method="_on_switch_pressed"] diff --git a/loading/background_load/project.godot b/loading/background_load/project.godot deleted file mode 100644 index d892ea9e..00000000 --- a/loading/background_load/project.godot +++ /dev/null @@ -1,109 +0,0 @@ -; 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 - -[application] - -config/name="Background Thread Loading Demo" -config/description="This is a demo showing how to use the load_interactive() method of -ResourceLoader to load large scenes in the background with a progress bar." -run/main_scene="res://paintings.tscn" - -[autoload] - -background_load="*res://background_load.tscn" - -[display] - -window/dpi/allow_hidpi=true -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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777221,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777222,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777218,"physical_keycode":0,"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,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -] -} -ui_left={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"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,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777235,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -] -} -ui_page_down={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777236,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -] -} -ui_home={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777229,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -] -} -ui_end={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777230,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -] -} - -[rendering] - -quality/driver/driver_name="GLES2" -vram_compression/import_etc=true -vram_compression/import_etc2=false diff --git a/loading/background_load/screenshots/paintings.png b/loading/background_load/screenshots/paintings.png deleted file mode 100644 index e290f0f1..00000000 Binary files a/loading/background_load/screenshots/paintings.png and /dev/null differ diff --git a/loading/background_load/sculptures.gd b/loading/background_load/sculptures.gd deleted file mode 100644 index 6274f646..00000000 --- a/loading/background_load/sculptures.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Node2D - -func _on_switch_pressed(): - $CanvasLayer/Switch.hide() - background_load.load_scene("res://paintings.tscn") diff --git a/loading/background_load/sculptures.tscn b/loading/background_load/sculptures.tscn deleted file mode 100644 index def9c3fe..00000000 --- a/loading/background_load/sculptures.tscn +++ /dev/null @@ -1,141 +0,0 @@ -[gd_scene load_steps=9 format=2] - -[ext_resource path="res://sculptures.gd" type="Script" id=1] -[ext_resource path="res://sculptures/sculpture_david.jpg" type="Texture2D" id=2] -[ext_resource path="res://sculptures/sculpture_fountain.jpg" type="Texture2D" id=3] -[ext_resource path="res://sculptures/sculpture_four_parts_of_earth.jpg" type="Texture2D" id=4] -[ext_resource path="res://sculptures/sculpture_lincoln.jpg" type="Texture2D" id=5] -[ext_resource path="res://sculptures/sculpture_thinker.jpg" type="Texture2D" id=6] -[ext_resource path="res://sculptures/sculpture_venus.png" type="Texture2D" id=7] - -[sub_resource type="Animation" id=1] -resource_name = "colorcycle" -length = 8.0 -loop = true -tracks/0/type = "value" -tracks/0/path = NodePath("FourPartsOfEarth:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 4), -"transitions": PackedFloat32Array(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("Fountain:modulate") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 4), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Lincoln:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 4.1), -"transitions": PackedFloat32Array(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("David:modulate") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 4.1), -"transitions": PackedFloat32Array(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("Thinker:modulate") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PackedFloat32Array(0, 4.1), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(1, 1, 1, 1), Color(0.898039, 0, 1, 1)] -} -tracks/5/type = "value" -tracks/5/path = NodePath("Venus:modulate") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PackedFloat32Array(0, 4.1), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(1, 1, 1, 1), Color(0, 0, 0, 1)] -} - -[node name="Sculptures" type="Node2D"] -script = ExtResource( 1 ) - -[node name="David" type="Sprite2D" parent="."] -position = Vector2(567.784, 196.577) -scale = Vector2(0.447348, 0.447348) -texture = ExtResource( 2 ) - -[node name="Fountain" type="Sprite2D" parent="."] -position = Vector2(152.971, 513.499) -scale = Vector2(0.191615, 0.191615) -texture = ExtResource( 3 ) - -[node name="FourPartsOfEarth" type="Sprite2D" parent="."] -position = Vector2(480.743, 588.027) -scale = Vector2(0.198693, 0.198693) -texture = ExtResource( 4 ) - -[node name="Lincoln" type="Sprite2D" parent="."] -position = Vector2(211.852, 203.688) -scale = Vector2(0.386179, 0.378971) -texture = ExtResource( 5 ) - -[node name="Thinker" type="Sprite2D" parent="."] -position = Vector2(854.336, 202.363) -scale = Vector2(0.182302, 0.182302) -texture = ExtResource( 6 ) - -[node name="Venus" type="Sprite2D" 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"] -offset_left = 10.0 -offset_top = 10.0 -offset_right = 142.0 -offset_bottom = 30.0 -text = "Switch to Paintings" -__meta__ = { -"_edit_use_anchors_": false -} - -[connection signal="pressed" from="CanvasLayer/Switch" to="." method="_on_switch_pressed"] diff --git a/loading/background_load/sculptures/sculpture_david.jpg b/loading/background_load/sculptures/sculpture_david.jpg deleted file mode 100644 index 17d233af..00000000 Binary files a/loading/background_load/sculptures/sculpture_david.jpg and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_david.jpg.import b/loading/background_load/sculptures/sculpture_david.jpg.import deleted file mode 100644 index 66ff7451..00000000 --- a/loading/background_load/sculptures/sculpture_david.jpg.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_david.jpg-a970dbaef2d14bf5b95bd6bc742cc5b7.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_david.jpg" -dest_files=["res://.godot/imported/sculpture_david.jpg-a970dbaef2d14bf5b95bd6bc742cc5b7.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/background_load/sculptures/sculpture_fountain.jpg b/loading/background_load/sculptures/sculpture_fountain.jpg deleted file mode 100644 index b5dfb983..00000000 Binary files a/loading/background_load/sculptures/sculpture_fountain.jpg and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_fountain.jpg.import b/loading/background_load/sculptures/sculpture_fountain.jpg.import deleted file mode 100644 index c06ef10f..00000000 --- a/loading/background_load/sculptures/sculpture_fountain.jpg.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_fountain.jpg-c97f66cd28cbdedd878a6bccaee9f8ab.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_fountain.jpg" -dest_files=["res://.godot/imported/sculpture_fountain.jpg-c97f66cd28cbdedd878a6bccaee9f8ab.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg b/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg deleted file mode 100644 index ae04771e..00000000 Binary files a/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg.import b/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg.import deleted file mode 100644 index 7e75b025..00000000 --- a/loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_four_parts_of_earth.jpg-3a91357b6e4b11dc5c9d6cf4e883ae09.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_four_parts_of_earth.jpg" -dest_files=["res://.godot/imported/sculpture_four_parts_of_earth.jpg-3a91357b6e4b11dc5c9d6cf4e883ae09.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/background_load/sculptures/sculpture_lincoln.jpg b/loading/background_load/sculptures/sculpture_lincoln.jpg deleted file mode 100644 index 12fe4356..00000000 Binary files a/loading/background_load/sculptures/sculpture_lincoln.jpg and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_lincoln.jpg.import b/loading/background_load/sculptures/sculpture_lincoln.jpg.import deleted file mode 100644 index 432aeaf4..00000000 --- a/loading/background_load/sculptures/sculpture_lincoln.jpg.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_lincoln.jpg-6788997c8779fe1e17e7199d4f455ddd.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_lincoln.jpg" -dest_files=["res://.godot/imported/sculpture_lincoln.jpg-6788997c8779fe1e17e7199d4f455ddd.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/background_load/sculptures/sculpture_thinker.jpg b/loading/background_load/sculptures/sculpture_thinker.jpg deleted file mode 100644 index 40227458..00000000 Binary files a/loading/background_load/sculptures/sculpture_thinker.jpg and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_thinker.jpg.import b/loading/background_load/sculptures/sculpture_thinker.jpg.import deleted file mode 100644 index 18cd4a3c..00000000 --- a/loading/background_load/sculptures/sculpture_thinker.jpg.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_thinker.jpg-09c1107239db80502d91eb2eed125d58.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_thinker.jpg" -dest_files=["res://.godot/imported/sculpture_thinker.jpg-09c1107239db80502d91eb2eed125d58.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/background_load/sculptures/sculpture_venus.png b/loading/background_load/sculptures/sculpture_venus.png deleted file mode 100644 index 1fa157e7..00000000 Binary files a/loading/background_load/sculptures/sculpture_venus.png and /dev/null differ diff --git a/loading/background_load/sculptures/sculpture_venus.png.import b/loading/background_load/sculptures/sculpture_venus.png.import deleted file mode 100644 index e8ec674d..00000000 --- a/loading/background_load/sculptures/sculpture_venus.png.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/sculpture_venus.png-f25859b819e865591053766b700269eb.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sculptures/sculpture_venus.png" -dest_files=["res://.godot/imported/sculpture_venus.png-f25859b819e865591053766b700269eb.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 -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/loading/load_threaded/README.md b/loading/load_threaded/README.md new file mode 100644 index 00000000..588f73b0 --- /dev/null +++ b/loading/load_threaded/README.md @@ -0,0 +1,13 @@ +# Threaded Loading + +This demo demonstrates how to use ResourceLoader for background loading. + +Language: GDScript + +Renderer: Mobile + +Check out this demo on the asset library: *Coming soon* + +## Screenshots + +![Screenshot](screenshots/paintings.png) diff --git a/loading/load_threaded/icon.png b/loading/load_threaded/icon.png new file mode 100644 index 00000000..0de2ae14 Binary files /dev/null and b/loading/load_threaded/icon.png differ diff --git a/loading/multiple_threads_loading/icon.png.import b/loading/load_threaded/icon.png.import similarity index 56% rename from loading/multiple_threads_loading/icon.png.import rename to loading/load_threaded/icon.png.import index 889af9df..afa66e24 100644 --- a/loading/multiple_threads_loading/icon.png.import +++ b/loading/load_threaded/icon.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +type="CompressedTexture2D" +uid="uid://y4rcaycsgn4r" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://icon.png" -dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"] +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/load_threaded/load_threaded.gd b/loading/load_threaded/load_threaded.gd new file mode 100644 index 00000000..fdc4fa39 --- /dev/null +++ b/loading/load_threaded/load_threaded.gd @@ -0,0 +1,42 @@ +extends VBoxContainer + + +func _on_start_loading_pressed(): + ResourceLoader.load_threaded_request("res://paintings/painting_babel.jpg") + ResourceLoader.load_threaded_request("res://paintings/painting_las_meninas.png") + ResourceLoader.load_threaded_request("res://paintings/painting_mona_lisa.jpg") + ResourceLoader.load_threaded_request("res://paintings/painting_old_guitarist.jpg") + ResourceLoader.load_threaded_request("res://paintings/painting_parasol.jpg") + ResourceLoader.load_threaded_request("res://paintings/painting_the_swing.jpg") + for current_button in $GetLoaded.get_children(): + current_button.disabled = false + + +func _on_babel_pressed(): + $Paintings/Babel.texture = ResourceLoader.load_threaded_get("res://paintings/painting_babel.jpg") + $GetLoaded/Babel.disabled = true + + +func _on_las_meninas_pressed(): + $Paintings/LasMeninas.texture = ResourceLoader.load_threaded_get("res://paintings/painting_las_meninas.png") + $GetLoaded/LasMeninas.disabled = true + + +func _on_mona_lisa_pressed(): + $Paintings/MonaLisa.texture = ResourceLoader.load_threaded_get("res://paintings/painting_mona_lisa.jpg") + $GetLoaded/MonaLisa.disabled = true + + +func _on_old_guitarist_pressed(): + $Paintings/OldGuitarist.texture = ResourceLoader.load_threaded_get("res://paintings/painting_old_guitarist.jpg") + $GetLoaded/OldGuitarist.disabled = true + + +func _on_parasol_pressed(): + $Paintings/Parasol.texture = ResourceLoader.load_threaded_get("res://paintings/painting_parasol.jpg") + $GetLoaded/Parasol.disabled = true + + +func _on_swing_pressed(): + $Paintings/Swing.texture = ResourceLoader.load_threaded_get("res://paintings/painting_the_swing.jpg") + $GetLoaded/Swing.disabled = true diff --git a/loading/load_threaded/load_threaded.tscn b/loading/load_threaded/load_threaded.tscn new file mode 100644 index 00000000..975566bd --- /dev/null +++ b/loading/load_threaded/load_threaded.tscn @@ -0,0 +1,102 @@ +[gd_scene load_steps=2 format=3 uid="uid://gc6pbdkdi7xt"] + +[ext_resource type="Script" path="res://load_threaded.gd" id="1_5o27a"] + +[node name="LoadThreaded" type="VBoxContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_5o27a") + +[node name="Paintings" type="HBoxContainer" parent="."] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Babel" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="LasMeninas" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="MonaLisa" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="OldGuitarist" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="Parasol" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="Swing" type="TextureRect" parent="Paintings"] +layout_mode = 2 +size_flags_horizontal = 3 +ignore_texture_size = true +stretch_mode = 5 + +[node name="StartLoading" type="Button" parent="."] +layout_mode = 2 +text = "Start Loading" + +[node name="GetLoaded" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="Babel" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "The Tower of Babel" + +[node name="LasMeninas" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "Las Meninas" + +[node name="MonaLisa" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "Mona Lisa" + +[node name="OldGuitarist" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "The Old Guitarist" + +[node name="Parasol" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "Woman with a Parasol – Madame Monet and Her Son" + +[node name="Swing" type="Button" parent="GetLoaded"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "The Swing" + +[connection signal="pressed" from="StartLoading" to="." method="_on_start_loading_pressed"] +[connection signal="pressed" from="GetLoaded/Babel" to="." method="_on_babel_pressed"] +[connection signal="pressed" from="GetLoaded/LasMeninas" to="." method="_on_las_meninas_pressed"] +[connection signal="pressed" from="GetLoaded/MonaLisa" to="." method="_on_mona_lisa_pressed"] +[connection signal="pressed" from="GetLoaded/OldGuitarist" to="." method="_on_old_guitarist_pressed"] +[connection signal="pressed" from="GetLoaded/Parasol" to="." method="_on_parasol_pressed"] +[connection signal="pressed" from="GetLoaded/Swing" to="." method="_on_swing_pressed"] diff --git a/loading/background_load/paintings/painting_babel.jpg b/loading/load_threaded/paintings/painting_babel.jpg similarity index 100% rename from loading/background_load/paintings/painting_babel.jpg rename to loading/load_threaded/paintings/painting_babel.jpg diff --git a/loading/background_load/paintings/painting_babel.jpg.import b/loading/load_threaded/paintings/painting_babel.jpg.import similarity index 56% rename from loading/background_load/paintings/painting_babel.jpg.import rename to loading/load_threaded/paintings/painting_babel.jpg.import index 0429b427..f195b42b 100644 --- a/loading/background_load/paintings/painting_babel.jpg.import +++ b/loading/load_threaded/paintings/painting_babel.jpg.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.stex" +type="CompressedTexture2D" +uid="uid://y5tmlxhhiv2u" +path="res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_babel.jpg" -dest_files=["res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.stex"] +dest_files=["res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/background_load/paintings/painting_las_meninas.png b/loading/load_threaded/paintings/painting_las_meninas.png similarity index 99% rename from loading/background_load/paintings/painting_las_meninas.png rename to loading/load_threaded/paintings/painting_las_meninas.png index a9b841b7..f4cdef90 100644 Binary files a/loading/background_load/paintings/painting_las_meninas.png and b/loading/load_threaded/paintings/painting_las_meninas.png differ diff --git a/loading/background_load/paintings/painting_las_meninas.png.import b/loading/load_threaded/paintings/painting_las_meninas.png.import similarity index 55% rename from loading/background_load/paintings/painting_las_meninas.png.import rename to loading/load_threaded/paintings/painting_las_meninas.png.import index a0fed096..fdc660d6 100644 --- a/loading/background_load/paintings/painting_las_meninas.png.import +++ b/loading/load_threaded/paintings/painting_las_meninas.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.stex" +type="CompressedTexture2D" +uid="uid://d1pbl328jrf0k" +path="res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_las_meninas.png" -dest_files=["res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.stex"] +dest_files=["res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/background_load/paintings/painting_mona_lisa.jpg b/loading/load_threaded/paintings/painting_mona_lisa.jpg similarity index 100% rename from loading/background_load/paintings/painting_mona_lisa.jpg rename to loading/load_threaded/paintings/painting_mona_lisa.jpg diff --git a/loading/background_load/paintings/painting_mona_lisa.jpg.import b/loading/load_threaded/paintings/painting_mona_lisa.jpg.import similarity index 55% rename from loading/background_load/paintings/painting_mona_lisa.jpg.import rename to loading/load_threaded/paintings/painting_mona_lisa.jpg.import index ef031990..a59de265 100644 --- a/loading/background_load/paintings/painting_mona_lisa.jpg.import +++ b/loading/load_threaded/paintings/painting_mona_lisa.jpg.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.stex" +type="CompressedTexture2D" +uid="uid://bad1drr2you5e" +path="res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_mona_lisa.jpg" -dest_files=["res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.stex"] +dest_files=["res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/background_load/paintings/painting_old_guitarist.jpg b/loading/load_threaded/paintings/painting_old_guitarist.jpg similarity index 100% rename from loading/background_load/paintings/painting_old_guitarist.jpg rename to loading/load_threaded/paintings/painting_old_guitarist.jpg diff --git a/loading/background_load/paintings/painting_old_guitarist.jpg.import b/loading/load_threaded/paintings/painting_old_guitarist.jpg.import similarity index 55% rename from loading/background_load/paintings/painting_old_guitarist.jpg.import rename to loading/load_threaded/paintings/painting_old_guitarist.jpg.import index da0baecd..fee40f46 100644 --- a/loading/background_load/paintings/painting_old_guitarist.jpg.import +++ b/loading/load_threaded/paintings/painting_old_guitarist.jpg.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.stex" +type="CompressedTexture2D" +uid="uid://bn3aufteoq2sa" +path="res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_old_guitarist.jpg" -dest_files=["res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.stex"] +dest_files=["res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/background_load/paintings/painting_parasol.jpg b/loading/load_threaded/paintings/painting_parasol.jpg similarity index 100% rename from loading/background_load/paintings/painting_parasol.jpg rename to loading/load_threaded/paintings/painting_parasol.jpg diff --git a/loading/background_load/paintings/painting_parasol.jpg.import b/loading/load_threaded/paintings/painting_parasol.jpg.import similarity index 56% rename from loading/background_load/paintings/painting_parasol.jpg.import rename to loading/load_threaded/paintings/painting_parasol.jpg.import index fbce0f9d..b5a33b51 100644 --- a/loading/background_load/paintings/painting_parasol.jpg.import +++ b/loading/load_threaded/paintings/painting_parasol.jpg.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.stex" +type="CompressedTexture2D" +uid="uid://qut3pkm72hge" +path="res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_parasol.jpg" -dest_files=["res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.stex"] +dest_files=["res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/background_load/paintings/painting_the_swing.jpg b/loading/load_threaded/paintings/painting_the_swing.jpg similarity index 100% rename from loading/background_load/paintings/painting_the_swing.jpg rename to loading/load_threaded/paintings/painting_the_swing.jpg diff --git a/loading/background_load/paintings/painting_the_swing.jpg.import b/loading/load_threaded/paintings/painting_the_swing.jpg.import similarity index 55% rename from loading/background_load/paintings/painting_the_swing.jpg.import rename to loading/load_threaded/paintings/painting_the_swing.jpg.import index 16f2be6a..23877d59 100644 --- a/loading/background_load/paintings/painting_the_swing.jpg.import +++ b/loading/load_threaded/paintings/painting_the_swing.jpg.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.stex" +type="CompressedTexture2D" +uid="uid://bqtsy0u0x7drj" +path="res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://paintings/painting_the_swing.jpg" -dest_files=["res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.stex"] +dest_files=["res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=true -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/load_threaded/project.godot b/loading/load_threaded/project.godot new file mode 100644 index 00000000..1e2d0b2a --- /dev/null +++ b/loading/load_threaded/project.godot @@ -0,0 +1,26 @@ +; 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=5 + +[application] + +config/name="Threaded Loading" +config/description="This demo demonstrates how to use ResourceLoader for background loading." +run/main_scene="res://load_threaded.tscn" +config/features=PackedStringArray("4.0") +run/low_processor_mode=true +config/icon="res://icon.png" + +[display] + +window/vsync/vsync_mode=0 + +[rendering] + +renderer/rendering_method="mobile" diff --git a/loading/background_load/screenshots/.gdignore b/loading/load_threaded/screenshots/.gdignore similarity index 100% rename from loading/background_load/screenshots/.gdignore rename to loading/load_threaded/screenshots/.gdignore diff --git a/loading/load_threaded/screenshots/paintings.png b/loading/load_threaded/screenshots/paintings.png new file mode 100644 index 00000000..5bcd3c9a Binary files /dev/null and b/loading/load_threaded/screenshots/paintings.png differ diff --git a/loading/multiple_threads_loading/README.md b/loading/multiple_threads_loading/README.md deleted file mode 100644 index 4345ac89..00000000 --- a/loading/multiple_threads_loading/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Multiple-threads loading demo - -This demo shows how you can organize -background loading using multiple threads. - -Language: GDScript - -Renderer: GLES 2 - -Check out this demo on the asset library: https://godotengine.org/asset-library/asset/582 - -## How does it work? - -[Official documentation - Using multiple threads](http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html#using-multiple-threads) - -## Screenshots - -![Screenshot](screenshots/screenshot.png) diff --git a/loading/multiple_threads_loading/icon.png b/loading/multiple_threads_loading/icon.png deleted file mode 100644 index 65024fbc..00000000 Binary files a/loading/multiple_threads_loading/icon.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/.gitignore b/loading/multiple_threads_loading/images/.gitignore deleted file mode 100644 index 4e23f0ac..00000000 --- a/loading/multiple_threads_loading/images/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# For this folder only, let's ignore all *.import files. -# Otherwise, there would be over a thousand lines committed for no benefit. -*.import diff --git a/loading/multiple_threads_loading/images/icon_1.png b/loading/multiple_threads_loading/images/icon_1.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_1.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_10.png b/loading/multiple_threads_loading/images/icon_10.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_10.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_11.png b/loading/multiple_threads_loading/images/icon_11.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_11.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_12.png b/loading/multiple_threads_loading/images/icon_12.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_12.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_13.png b/loading/multiple_threads_loading/images/icon_13.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_13.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_14.png b/loading/multiple_threads_loading/images/icon_14.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_14.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_15.png b/loading/multiple_threads_loading/images/icon_15.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_15.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_16.png b/loading/multiple_threads_loading/images/icon_16.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_16.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_17.png b/loading/multiple_threads_loading/images/icon_17.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_17.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_18.png b/loading/multiple_threads_loading/images/icon_18.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_18.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_19.png b/loading/multiple_threads_loading/images/icon_19.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_19.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_2.png b/loading/multiple_threads_loading/images/icon_2.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_2.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_20.png b/loading/multiple_threads_loading/images/icon_20.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_20.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_21.png b/loading/multiple_threads_loading/images/icon_21.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_21.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_22.png b/loading/multiple_threads_loading/images/icon_22.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_22.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_23.png b/loading/multiple_threads_loading/images/icon_23.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_23.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_24.png b/loading/multiple_threads_loading/images/icon_24.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_24.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_25.png b/loading/multiple_threads_loading/images/icon_25.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_25.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_26.png b/loading/multiple_threads_loading/images/icon_26.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_26.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_27.png b/loading/multiple_threads_loading/images/icon_27.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_27.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_28.png b/loading/multiple_threads_loading/images/icon_28.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_28.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_29.png b/loading/multiple_threads_loading/images/icon_29.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_29.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_3.png b/loading/multiple_threads_loading/images/icon_3.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_3.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_30.png b/loading/multiple_threads_loading/images/icon_30.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_30.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_31.png b/loading/multiple_threads_loading/images/icon_31.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_31.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_32.png b/loading/multiple_threads_loading/images/icon_32.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_32.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_33.png b/loading/multiple_threads_loading/images/icon_33.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_33.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_34.png b/loading/multiple_threads_loading/images/icon_34.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_34.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_35.png b/loading/multiple_threads_loading/images/icon_35.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_35.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_36.png b/loading/multiple_threads_loading/images/icon_36.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_36.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_37.png b/loading/multiple_threads_loading/images/icon_37.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_37.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_38.png b/loading/multiple_threads_loading/images/icon_38.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_38.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_39.png b/loading/multiple_threads_loading/images/icon_39.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_39.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_4.png b/loading/multiple_threads_loading/images/icon_4.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_4.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_40.png b/loading/multiple_threads_loading/images/icon_40.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_40.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_5.png b/loading/multiple_threads_loading/images/icon_5.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_5.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_6.png b/loading/multiple_threads_loading/images/icon_6.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_6.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_7.png b/loading/multiple_threads_loading/images/icon_7.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_7.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_8.png b/loading/multiple_threads_loading/images/icon_8.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_8.png and /dev/null differ diff --git a/loading/multiple_threads_loading/images/icon_9.png b/loading/multiple_threads_loading/images/icon_9.png deleted file mode 100644 index b05c13c9..00000000 Binary files a/loading/multiple_threads_loading/images/icon_9.png and /dev/null differ diff --git a/loading/multiple_threads_loading/link_button.gd b/loading/multiple_threads_loading/link_button.gd deleted file mode 100644 index 736eafba..00000000 --- a/loading/multiple_threads_loading/link_button.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends LinkButton - -func _on_LinkButton_button_up(): - # warning-ignore:return_value_discarded - OS.shell_open("http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html#using-multiple-threads") diff --git a/loading/multiple_threads_loading/main.tscn b/loading/multiple_threads_loading/main.tscn deleted file mode 100644 index c4e0e469..00000000 --- a/loading/multiple_threads_loading/main.tscn +++ /dev/null @@ -1,219 +0,0 @@ -[gd_scene load_steps=41 format=2] - -[ext_resource path="res://images/icon_1.png" type="Texture2D" id=1] -[ext_resource path="res://images/icon_2.png" type="Texture2D" id=2] -[ext_resource path="res://images/icon_3.png" type="Texture2D" id=3] -[ext_resource path="res://images/icon_4.png" type="Texture2D" id=4] -[ext_resource path="res://images/icon_5.png" type="Texture2D" id=5] -[ext_resource path="res://images/icon_6.png" type="Texture2D" id=6] -[ext_resource path="res://images/icon_7.png" type="Texture2D" id=7] -[ext_resource path="res://images/icon_8.png" type="Texture2D" id=8] -[ext_resource path="res://images/icon_9.png" type="Texture2D" id=9] -[ext_resource path="res://images/icon_10.png" type="Texture2D" id=10] -[ext_resource path="res://images/icon_11.png" type="Texture2D" id=11] -[ext_resource path="res://images/icon_12.png" type="Texture2D" id=12] -[ext_resource path="res://images/icon_13.png" type="Texture2D" id=13] -[ext_resource path="res://images/icon_14.png" type="Texture2D" id=14] -[ext_resource path="res://images/icon_15.png" type="Texture2D" id=15] -[ext_resource path="res://images/icon_16.png" type="Texture2D" id=16] -[ext_resource path="res://images/icon_17.png" type="Texture2D" id=17] -[ext_resource path="res://images/icon_18.png" type="Texture2D" id=18] -[ext_resource path="res://images/icon_19.png" type="Texture2D" id=19] -[ext_resource path="res://images/icon_20.png" type="Texture2D" id=20] -[ext_resource path="res://images/icon_21.png" type="Texture2D" id=21] -[ext_resource path="res://images/icon_22.png" type="Texture2D" id=22] -[ext_resource path="res://images/icon_23.png" type="Texture2D" id=23] -[ext_resource path="res://images/icon_24.png" type="Texture2D" id=24] -[ext_resource path="res://images/icon_25.png" type="Texture2D" id=25] -[ext_resource path="res://images/icon_26.png" type="Texture2D" id=26] -[ext_resource path="res://images/icon_27.png" type="Texture2D" id=27] -[ext_resource path="res://images/icon_28.png" type="Texture2D" id=28] -[ext_resource path="res://images/icon_29.png" type="Texture2D" id=29] -[ext_resource path="res://images/icon_30.png" type="Texture2D" id=30] -[ext_resource path="res://images/icon_31.png" type="Texture2D" id=31] -[ext_resource path="res://images/icon_32.png" type="Texture2D" id=32] -[ext_resource path="res://images/icon_33.png" type="Texture2D" id=33] -[ext_resource path="res://images/icon_34.png" type="Texture2D" id=34] -[ext_resource path="res://images/icon_35.png" type="Texture2D" id=35] -[ext_resource path="res://images/icon_36.png" type="Texture2D" id=36] -[ext_resource path="res://images/icon_37.png" type="Texture2D" id=37] -[ext_resource path="res://images/icon_38.png" type="Texture2D" id=38] -[ext_resource path="res://images/icon_39.png" type="Texture2D" id=39] -[ext_resource path="res://images/icon_40.png" type="Texture2D" id=40] - -[node name="Node" type="Node"] - -[node name="ColorRect" type="ColorRect" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color(0, 0, 0, 1) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Label" type="Label" parent="."] -offset_left = 452.0 -offset_top = 272.0 -offset_right = 572.0 -offset_bottom = 286.0 -text = "Main scene loaded" - -[node name="Sprite1" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 1 ) - -[node name="Sprite2" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 2 ) - -[node name="Sprite3" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 3 ) - -[node name="Sprite4" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 4 ) - -[node name="Sprite5" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 5 ) - -[node name="Sprite6" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 6 ) - -[node name="Sprite7" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 7 ) - -[node name="Sprite8" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 8 ) - -[node name="Sprite9" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 9 ) - -[node name="Sprite10" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 10 ) - -[node name="Sprite11" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 11 ) - -[node name="Sprite12" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 12 ) - -[node name="Sprite13" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 13 ) - -[node name="Sprite14" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 14 ) - -[node name="Sprite15" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 15 ) - -[node name="Sprite16" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 16 ) - -[node name="Sprite17" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 17 ) - -[node name="Sprite18" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 18 ) - -[node name="Sprite19" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 19 ) - -[node name="Sprite20" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 20 ) - -[node name="Sprite21" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 21 ) - -[node name="Sprite22" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 22 ) - -[node name="Sprite23" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 23 ) - -[node name="Sprite24" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 24 ) - -[node name="Sprite25" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 25 ) - -[node name="Sprite26" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 26 ) - -[node name="Sprite27" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 27 ) - -[node name="Sprite28" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 28 ) - -[node name="Sprite29" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 29 ) - -[node name="Sprite30" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 30 ) - -[node name="Sprite31" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 31 ) - -[node name="Sprite32" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 32 ) - -[node name="Sprite33" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 33 ) - -[node name="Sprite34" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 34 ) - -[node name="Sprite35" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 35 ) - -[node name="Sprite36" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 36 ) - -[node name="Sprite37" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 37 ) - -[node name="Sprite38" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 38 ) - -[node name="Sprite39" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 39 ) - -[node name="Sprite40" type="Sprite2D" parent="."] -visible = false -texture = ExtResource( 40 ) diff --git a/loading/multiple_threads_loading/preload.gd b/loading/multiple_threads_loading/preload.gd deleted file mode 100644 index bb7694b7..00000000 --- a/loading/multiple_threads_loading/preload.gd +++ /dev/null @@ -1,33 +0,0 @@ -extends Node - - -var queue - - -func _ready(): - # Initialize. - queue = preload("res://resource_queue.gd").new() - # Call after you instance the class to start the thread. - queue.start() - - -func _process(_delta): - # Returns true if a resource is done loading and ready to be retrieved. - if queue.is_ready("res://main.tscn"): - set_process(false) - # Returns the fully loaded resource. - var next_scene = queue.get_resource("res://main.tscn").instantiate() - get_node(^"/root").add_child(next_scene) - get_node(^"/root").remove_child(self) - queue_free() - else: - # Get the progress of a resource. - var progress = round(queue.get_progress("res://main.tscn") * 100) - get_node(^"ProgressBar").set_value(progress) - - -func _on_Button_button_up(): - get_node(^"Button").hide() - set_process(true) - # Queue a resource. - queue.queue_resource("res://main.tscn", true) diff --git a/loading/multiple_threads_loading/preload.tscn b/loading/multiple_threads_loading/preload.tscn deleted file mode 100644 index 37798013..00000000 --- a/loading/multiple_threads_loading/preload.tscn +++ /dev/null @@ -1,65 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://preload.gd" type="Script" id=1] -[ext_resource path="res://link_button.gd" type="Script" id=2] - -[node name="Node" type="Node"] -script = ExtResource( 1 ) - -[node name="ColorRect" type="ColorRect" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color(0.00390625, 0, 0, 1) - -[node name="ProgressBar" type="ProgressBar" parent="."] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -225.0 -offset_top = -66.0 -offset_right = 225.0 -offset_bottom = 66.0 -step = 1.0 - -[node name="Button" type="Button" parent="."] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -223.0 -offset_top = -193.0 -offset_right = 224.0 -offset_bottom = -84.0 -text = "Load next scene" - -[node name="Label" type="Label" parent="."] -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -267.0 -offset_top = 12.0 -offset_right = 267.0 -offset_bottom = 82.0 -text = "Multiple-treads loading demo -The next scene contains 40 resource files. Loading is done using multiple threads. -The download speed depends on the performance of your device. -For more information, see:" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="LinkButton" type="LinkButton" parent="."] -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -233.0 -offset_top = 80.0 -offset_right = 233.0 -offset_bottom = 94.0 -text = "http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html" -script = ExtResource( 2 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[connection signal="button_up" from="Button" to="." method="_on_Button_button_up"] -[connection signal="button_up" from="LinkButton" to="LinkButton" method="_on_LinkButton_button_up"] diff --git a/loading/multiple_threads_loading/project.godot b/loading/multiple_threads_loading/project.godot deleted file mode 100644 index 53792e32..00000000 --- a/loading/multiple_threads_loading/project.godot +++ /dev/null @@ -1,23 +0,0 @@ -; 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 - -[application] - -config/name="Multiple threads loading" -config/description="This demo shows how you can organize -background loading using multiple threads." -run/main_scene="res://preload.tscn" -config/icon="res://icon.png" - -[rendering] - -quality/driver/driver_name="GLES2" -vram_compression/import_etc=true -vram_compression/import_etc2=false diff --git a/loading/multiple_threads_loading/resource_queue.gd b/loading/multiple_threads_loading/resource_queue.gd deleted file mode 100644 index 0dc95bdd..00000000 --- a/loading/multiple_threads_loading/resource_queue.gd +++ /dev/null @@ -1,145 +0,0 @@ -var thread -var mutex -var sem - -var time_max = 100 # Milliseconds. - -var queue = [] -var pending = {} - -func _lock(_caller): - mutex.lock() - - -func _unlock(_caller): - mutex.unlock() - - -func _post(_caller): - sem.post() - - -func _wait(_caller): - sem.wait() - - -func queue_resource(path, p_in_front = false): - _lock("queue_resource") - if path in pending: - _unlock("queue_resource") - return - elif ResourceLoader.has_cached(path): - var res = ResourceLoader.load(path) - pending[path] = res - _unlock("queue_resource") - return - else: - var res = ResourceLoader.load_interactive(path) - res.set_meta("path", path) - if p_in_front: - queue.insert(0, res) - else: - queue.push_back(res) - pending[path] = res - _post("queue_resource") - _unlock("queue_resource") - return - - -func cancel_resource(path): - _lock("cancel_resource") - if path in pending: - if pending[path] is ResourceInteractiveLoader: - queue.erase(pending[path]) - pending.erase(path) - _unlock("cancel_resource") - - -func get_progress(path): - _lock("get_progress") - var ret = -1 - if path in pending: - if pending[path] is ResourceInteractiveLoader: - ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count()) - else: - ret = 1.0 - _unlock("get_progress") - return ret - - -func is_ready(path): - var ret - _lock("is_ready") - if path in pending: - ret = !(pending[path] is ResourceInteractiveLoader) - else: - ret = false - _unlock("is_ready") - return ret - - -func _wait_for_resource(res, path): - _unlock("wait_for_resource") - while true: - RenderingServer.sync() - OS.delay_usec(16000) # Wait approximately 1 frame. - _lock("wait_for_resource") - if queue.size() == 0 or queue[0] != res: - return pending[path] - _unlock("wait_for_resource") - - -func get_resource(path): - _lock("get_resource") - if path in pending: - if pending[path] is ResourceInteractiveLoader: - var res = pending[path] - if res != queue[0]: - var pos = queue.find(res) - queue.remove(pos) - queue.insert(0, res) - - res = _wait_for_resource(res, path) - pending.erase(path) - _unlock("return") - return res - else: - var res = pending[path] - pending.erase(path) - _unlock("return") - return res - else: - _unlock("return") - return ResourceLoader.load(path) - - -func thread_process(): - _wait("thread_process") - _lock("process") - - while queue.size() > 0: - var res = queue[0] - _unlock("process_poll") - var ret = res.poll() - _lock("process_check_queue") - - if ret == ERR_FILE_EOF or ret != OK: - var path = res.get_meta("path") - if path in pending: # Else, it was already retrieved. - pending[res.get_meta("path")] = res.get_resource() - # Something might have been put at the front of the queue while - # we polled, so use erase instead of remove. - queue.erase(res) - _unlock("process") - - -func thread_func(_u): - while true: - thread_process() - - -func start(): - mutex = Mutex.new() - sem = Semaphore.new() - thread = Thread.new() - thread.start(self, "thread_func", 0) diff --git a/loading/multiple_threads_loading/screenshots/.gdignore b/loading/multiple_threads_loading/screenshots/.gdignore deleted file mode 100644 index e69de29b..00000000 diff --git a/loading/multiple_threads_loading/screenshots/screenshot.png b/loading/multiple_threads_loading/screenshots/screenshot.png deleted file mode 100644 index 56781f90..00000000 Binary files a/loading/multiple_threads_loading/screenshots/screenshot.png and /dev/null differ diff --git a/loading/scene_changer/README.md b/loading/scene_changer/README.md index c633aed3..65c9d614 100644 --- a/loading/scene_changer/README.md +++ b/loading/scene_changer/README.md @@ -1,10 +1,10 @@ # Scene Changer -This uses functions in SceneTree to switch between two scenes. +This uses two functions in SceneTree to switch between two scenes. Language: GDScript -Renderer: GLES 2 +Renderer: Mobile Check out this demo on the asset library: https://godotengine.org/asset-library/asset/531 diff --git a/loading/scene_changer/icon.svg b/loading/scene_changer/icon.svg new file mode 100644 index 00000000..ac05d972 --- /dev/null +++ b/loading/scene_changer/icon.svg @@ -0,0 +1 @@ + diff --git a/loading/scene_changer/icon.svg.import b/loading/scene_changer/icon.svg.import new file mode 100644 index 00000000..10e51708 --- /dev/null +++ b/loading/scene_changer/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d1gie2ntmqic3" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/loading/scene_changer/project.godot b/loading/scene_changer/project.godot index 7f3a3586..1bffa3d1 100644 --- a/loading/scene_changer/project.godot +++ b/loading/scene_changer/project.godot @@ -6,13 +6,16 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 +config_version=5 [application] config/name="Scene Changer" config/description="This uses functions in SceneTree to switch between two scenes." run/main_scene="res://scene_a.tscn" +config/features=PackedStringArray("4.0") +run/low_processor_mode=true +config/icon="res://icon.svg" [debug] @@ -20,16 +23,8 @@ gdscript/warnings/return_value_discarded=false [display] -window/dpi/allow_hidpi=true -window/stretch/mode="2d" -window/stretch/aspect="expand" - -[gdnative] - -singletons=[] +window/vsync/vsync_mode=0 [rendering] -quality/driver/driver_name="GLES2" -vram_compression/import_etc=true -vram_compression/import_etc2=false +renderer/rendering_method="mobile" diff --git a/loading/scene_changer/scene_a.gd b/loading/scene_changer/scene_a.gd index f3e4efeb..14a2fdc9 100644 --- a/loading/scene_changer/scene_a.gd +++ b/loading/scene_changer/scene_a.gd @@ -1,4 +1,6 @@ extends Panel + func _on_goto_scene_pressed(): - get_tree().change_scene("res://scene_b.tscn") + # Change the scene to the one located at the given path. + get_tree().change_scene_to_file("res://scene_b.tscn") diff --git a/loading/scene_changer/scene_a.tscn b/loading/scene_changer/scene_a.tscn index e508ac73..5f56ef16 100644 --- a/loading/scene_changer/scene_a.tscn +++ b/loading/scene_changer/scene_a.tscn @@ -1,18 +1,19 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://dnveeke63vq8x"] -[ext_resource path="res://scene_a.gd" type="Script" id=1] +[ext_resource type="Script" path="res://scene_a.gd" id="1"] [node name="SceneA" type="Panel"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 2 size_flags_vertical = 2 -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("1") [node name="Label" type="Label" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 48.0 offset_right = 104.0 @@ -21,6 +22,7 @@ size_flags_vertical = 0 text = "This is scene A." [node name="GoToScene" type="Button" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 128.0 offset_right = 192.0 @@ -28,8 +30,5 @@ offset_bottom = 160.0 size_flags_horizontal = 2 size_flags_vertical = 2 text = "Go to Scene B" -__meta__ = { -"_edit_use_anchors_": false -} [connection signal="pressed" from="GoToScene" to="." method="_on_goto_scene_pressed"] diff --git a/loading/scene_changer/scene_b.gd b/loading/scene_changer/scene_b.gd index 80c3156d..6c5a372b 100644 --- a/loading/scene_changer/scene_b.gd +++ b/loading/scene_changer/scene_b.gd @@ -1,4 +1,9 @@ extends Panel + func _on_goto_scene_pressed(): - get_tree().change_scene("res://scene_a.tscn") + # Change the scene to the given PackedScene. + # Though it usually takes more code, this can have advantages, such as letting you load the + # scene in another thread, or use a scene that isn't saved to a file. + var scene := load("res://scene_a.tscn") as PackedScene + get_tree().change_scene_to_packed(scene) diff --git a/loading/scene_changer/scene_b.tscn b/loading/scene_changer/scene_b.tscn index ab3bf7d6..e3b4110f 100644 --- a/loading/scene_changer/scene_b.tscn +++ b/loading/scene_changer/scene_b.tscn @@ -1,18 +1,19 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://c71ureg6hk2u1"] -[ext_resource path="res://scene_b.gd" type="Script" id=1] +[ext_resource type="Script" path="res://scene_b.gd" id="1"] [node name="SceneB" type="Panel"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 2 size_flags_vertical = 2 -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("1") [node name="Label" type="Label" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 48.0 offset_right = 164.0 @@ -21,6 +22,7 @@ size_flags_vertical = 0 text = "This is scene B." [node name="GoToScene" type="Button" parent="."] +layout_mode = 0 offset_left = 64.0 offset_top = 128.0 offset_right = 192.0 diff --git a/loading/scene_changer/screenshots/scene_changer.png b/loading/scene_changer/screenshots/scene_changer.png index addb2500..c9256082 100644 Binary files a/loading/scene_changer/screenshots/scene_changer.png and b/loading/scene_changer/screenshots/scene_changer.png differ diff --git a/loading/serialization/README.md b/loading/serialization/README.md index 259548fe..058f388f 100644 --- a/loading/serialization/README.md +++ b/loading/serialization/README.md @@ -13,7 +13,7 @@ https://docs.godotengine.org/en/latest/tutorials/io/saving_games.html Language: GDScript -Renderer: GLES 2 +Renderer: Mobile Check out this demo on the asset library: https://godotengine.org/asset-library/asset/891 diff --git a/loading/serialization/enemy.gd b/loading/serialization/enemy.gd index a0f9324f..fab68791 100644 --- a/loading/serialization/enemy.gd +++ b/loading/serialization/enemy.gd @@ -1,29 +1,30 @@ -extends CharacterBody2D - -const MOVE_SPEED = 75 -const DAMAGE_PER_SECOND = 15 - -# The node we should be "attacking" every frame. -# If `null`, nobody is in range to attack. -var attacking = null +class_name Enemy extends Node2D -func _process(delta): - if attacking: +## Movement speed in pixels per second. +const MOVEMENT_SPEED = 75.0 +const DAMAGE_PER_SECOND = 15.0 + +## The node we should be "attacking" every frame. +## If [code]null[/code], nobody is in range to attack. +var attacking: Player = null + + +func _process(delta: float): + if is_instance_valid(attacking): attacking.health -= delta * DAMAGE_PER_SECOND - # warning-ignore:return_value_discarded - move_and_slide(Vector2(MOVE_SPEED, 0)) + position.x += MOVEMENT_SPEED * delta # The enemy went outside of the window. Move it back to the left. if position.x >= 732: position.x = -32 -func _on_AttackArea_body_entered(body): - if body.name == "Player": +func _on_attack_area_body_entered(body: PhysicsBody2D): + if body is Player: attacking = body -func _on_AttackArea_body_exited(_body): +func _on_attack_area_body_exited(_body: PhysicsBody2D): attacking = null diff --git a/loading/serialization/enemy.tscn b/loading/serialization/enemy.tscn index 1f67f792..1b066ffe 100644 --- a/loading/serialization/enemy.tscn +++ b/loading/serialization/enemy.tscn @@ -1,29 +1,25 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=3] -[ext_resource path="res://enemy.gd" type="Script" id=1] -[ext_resource path="res://icon.png" type="Texture2D" id=2] +[ext_resource type="Script" path="res://enemy.gd" id="1"] +[ext_resource type="Texture2D" path="res://enemy_crab.png" id="2_7p8lv"] -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2(32, 32) +[sub_resource type="RectangleShape2D" id="2"] +size = Vector2(76, 76) -[sub_resource type="RectangleShape2D" id=2] -extents = Vector2(38, 38) - -[node name="Enemy" type="CharacterBody2D" groups=["enemy"]] +[node name="Enemy" type="Node2D" groups=["enemy"]] position = Vector2(64, 160) -script = ExtResource( 1 ) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource( 1 ) +script = ExtResource("1") [node name="Sprite2D" type="Sprite2D" parent="."] -modulate = Color(2, 0.6, 0.5, 1) -texture = ExtResource( 2 ) +texture_filter = 1 +texture_repeat = 1 +scale = Vector2(4, 4) +texture = ExtResource("2_7p8lv") [node name="AttackArea" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="AttackArea"] -shape = SubResource( 2 ) +shape = SubResource("2") -[connection signal="body_entered" from="AttackArea" to="." method="_on_AttackArea_body_entered"] -[connection signal="body_exited" from="AttackArea" to="." method="_on_AttackArea_body_exited"] +[connection signal="body_entered" from="AttackArea" to="." method="_on_attack_area_body_entered"] +[connection signal="body_exited" from="AttackArea" to="." method="_on_attack_area_body_exited"] diff --git a/loading/serialization/enemy_crab.png b/loading/serialization/enemy_crab.png new file mode 100644 index 00000000..c9539221 Binary files /dev/null and b/loading/serialization/enemy_crab.png differ diff --git a/loading/serialization/enemy_crab.png.import b/loading/serialization/enemy_crab.png.import new file mode 100644 index 00000000..96fe50c1 --- /dev/null +++ b/loading/serialization/enemy_crab.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://btwwc5scaqp55" +path="res://.godot/imported/enemy_crab.png-3614508db77feac8d9a29bd3c8f780e8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemy_crab.png" +dest_files=["res://.godot/imported/enemy_crab.png-3614508db77feac8d9a29bd3c8f780e8.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/serialization/gui.gd b/loading/serialization/gui.gd index 258ba807..e4236ea0 100644 --- a/loading/serialization/gui.gd +++ b/loading/serialization/gui.gd @@ -2,12 +2,10 @@ extends VBoxContainer func _ready(): - var file = File.new() # Don't allow loading files that don't exist yet. - $SaveLoad/LoadConfigFile.disabled = not file.file_exists(ProjectSettings.globalize_path("user://save_config_file.ini")) - $SaveLoad/LoadJSON.disabled = not file.file_exists(ProjectSettings.globalize_path("user://save_json.json")) + ($SaveLoad/LoadConfigFile as Button).disabled = not FileAccess.file_exists("user://save_config_file.ini") + ($SaveLoad/LoadJSON as Button).disabled = not FileAccess.file_exists("user://save_json.json") func _on_open_user_data_folder_pressed(): - # warning-ignore:return_value_discarded OS.shell_open(ProjectSettings.globalize_path("user://")) diff --git a/loading/serialization/icon.png b/loading/serialization/icon.png index 6cb0ae71..a86f76ca 100644 Binary files a/loading/serialization/icon.png and b/loading/serialization/icon.png differ diff --git a/loading/serialization/icon.png.import b/loading/serialization/icon.png.import index 889af9df..22be900e 100644 --- a/loading/serialization/icon.png.import +++ b/loading/serialization/icon.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +type="CompressedTexture2D" +uid="uid://c0sgldp81v2h7" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://icon.png" -dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"] +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/serialization/player.gd b/loading/serialization/player.gd index 2b1b4db0..b2989c88 100644 --- a/loading/serialization/player.gd +++ b/loading/serialization/player.gd @@ -1,33 +1,38 @@ -extends CharacterBody2D +class_name Player extends CharacterBody2D -# The player's movement speed. -const MOVE_SPEED = 240 -var health = 100: +## Movement speed in pixels per second. +const MOVEMENT_SPEED = 240.0 + +var health := 100.0: + get: + return health set(value): - # TODO: Manually copy the code from this method. - set_health(value) -var motion = Vector2() + health = value + progress_bar.value = value + if health <= 0.0: + # The player died. + get_tree().reload_current_scene() +var motion := Vector2() -@onready var progress_bar = $Sprite2D/ProgressBar +@onready var progress_bar := $ProgressBar as ProgressBar +@onready var sprite := $Sprite2D as Sprite2D -func _process(delta): - # Player movement (controller-friendly). - var velocity = Vector2.ZERO - velocity.x = Input.get_axis(&"move_left", &"move_right") - velocity.y = Input.get_axis(&"move_up", &"move_down") - position += velocity * MOVE_SPEED * delta +func _process(_delta: float): + velocity = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down") + if velocity.length_squared() > 1.0: + velocity = velocity.normalized() + velocity *= MOVEMENT_SPEED + move_and_slide() - # Prevent the player from going outside the window. - position.x = clamp(position.x, 32, 700) - position.y = clamp(position.y, 32, 536) -func set_health(p_health): - health = p_health - progress_bar.value = health - - if health <= 0: - # The player died. - # warning-ignore:return_value_discarded - get_tree().reload_current_scene() +func _input(event: InputEvent): + if event.is_action_pressed(&"move_left"): + sprite.rotation = PI / 2 + elif event.is_action_pressed(&"move_right"): + sprite.rotation = -PI / 2 + elif event.is_action_pressed(&"move_up"): + sprite.rotation = PI + elif event.is_action_pressed(&"move_down"): + sprite.rotation = 0.0 diff --git a/loading/serialization/project.godot b/loading/serialization/project.godot index c062ea1d..bd6c1109 100644 --- a/loading/serialization/project.godot +++ b/loading/serialization/project.godot @@ -6,7 +6,23 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 +config_version=5 + +_global_script_classes=[{ +"base": "Node2D", +"class": &"Enemy", +"language": &"GDScript", +"path": "res://enemy.gd" +}, { +"base": "CharacterBody2D", +"class": &"Player", +"language": &"GDScript", +"path": "res://player.gd" +}] +_global_script_class_icons={ +"Enemy": "", +"Player": "" +} [application] @@ -17,55 +33,53 @@ format supported by Godot: ConfigFile and JSON. For more information, see this documentation article: https://docs.godotengine.org/en/latest/tutorials/io/saving_games.html" run/main_scene="res://save_load.tscn" +config/features=PackedStringArray("4.0") config/icon="res://icon.png" [display] -window/size/height=576 -window/stretch/mode="2d" -window/stretch/aspect="expand" +window/stretch/mode="canvas_items" [input] move_up={ "deadzone": 0.2, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194446,"physical_keycode":0,"unicode":0,"echo":false,"script":null) ] } move_down={ "deadzone": 0.2, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194440,"physical_keycode":0,"unicode":0,"echo":false,"script":null) ] } move_left={ "deadzone": 0.2, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194442,"physical_keycode":0,"unicode":0,"echo":false,"script":null) ] } move_right={ "deadzone": 0.2, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194444,"physical_keycode":0,"unicode":0,"echo":false,"script":null) ] } [rendering] -quality/driver/driver_name="GLES2" -vram_compression/import_etc=true -vram_compression/import_etc2=false -environment/default_clear_color=Color(0.133333, 0.2, 0.266667, 1) -environment/default_environment="res://default_env.tres" +renderer/rendering_method="mobile" +environment/defaults/default_clear_color=Color(0.24, 0.322667, 0.4, 1) diff --git a/loading/serialization/save_load.tscn b/loading/serialization/save_load.tscn index a8c1040d..50d6d700 100644 --- a/loading/serialization/save_load.tscn +++ b/loading/serialization/save_load.tscn @@ -1,28 +1,14 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=8 format=3 uid="uid://w7nl5fe4vheb"] -[ext_resource path="res://enemy.tscn" type="PackedScene" id=1] -[ext_resource path="res://gui.gd" type="Script" id=2] -[ext_resource path="res://save_load_json.gd" type="Script" id=3] -[ext_resource path="res://save_load_config_file.gd" type="Script" id=4] -[ext_resource path="res://icon.png" type="Texture2D" id=5] -[ext_resource path="res://player.gd" type="Script" id=6] +[ext_resource type="PackedScene" path="res://enemy.tscn" id="1"] +[ext_resource type="Script" path="res://gui.gd" id="2"] +[ext_resource type="Texture2D" uid="uid://dpm1oolm8wr02" path="res://sea_turtle.png" id="2_g2wd8"] +[ext_resource type="Script" path="res://save_load_json.gd" id="3"] +[ext_resource type="Script" path="res://save_load_config_file.gd" id="4"] +[ext_resource type="Script" path="res://player.gd" id="6"] -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2(32, 32) - -[sub_resource type="StyleBoxFlat" id=2] -bg_color = Color(0.45098, 1, 0.152941, 1) -corner_radius_top_left = 16 -corner_radius_top_right = 16 -corner_radius_bottom_right = 16 -corner_radius_bottom_left = 16 - -[sub_resource type="StyleBoxFlat" id=3] -bg_color = Color(0, 0, 0, 0.25098) -corner_radius_top_left = 16 -corner_radius_top_right = 16 -corner_radius_bottom_right = 16 -corner_radius_bottom_left = 16 +[sub_resource type="RectangleShape2D" id="1"] +size = Vector2(64, 64) [node name="Node" type="Node"] @@ -31,125 +17,96 @@ position = Vector2(296, 8) [node name="Player" type="CharacterBody2D" parent="Game"] position = Vector2(48, 40) -script = ExtResource( 6 ) +motion_mode = 1 +script = ExtResource("6") [node name="CollisionShape2D" type="CollisionShape2D" parent="Game/Player"] -shape = SubResource( 1 ) +shape = SubResource("1") [node name="Sprite2D" type="Sprite2D" parent="Game/Player"] -texture = ExtResource( 5 ) +texture_filter = 1 +scale = Vector2(4, 4) +texture = ExtResource("2_g2wd8") -[node name="ProgressBar" type="ProgressBar" parent="Game/Player/Sprite2D"] +[node name="ProgressBar" type="ProgressBar" parent="Game/Player"] offset_left = -32.0 -offset_top = -40.0 +offset_top = -48.0 offset_right = 32.0 -offset_bottom = -34.0 -custom_styles/fg = SubResource( 2 ) -custom_styles/bg = SubResource( 3 ) +offset_bottom = -32.0 value = 100.0 -percent_visible = false -__meta__ = { -"_edit_use_anchors_": false -} +show_percentage = false -[node name="Enemy" parent="Game" instance=ExtResource( 1 )] +[node name="Enemy" parent="Game" instance=ExtResource("1")] -[node name="Enemy2" parent="Game" instance=ExtResource( 1 )] +[node name="Enemy2" parent="Game" instance=ExtResource("1")] position = Vector2(376, 304) -[node name="Enemy3" parent="Game" instance=ExtResource( 1 )] +[node name="Enemy3" parent="Game" instance=ExtResource("1")] position = Vector2(232, 464) [node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 offset_left = 8.0 offset_top = 8.0 offset_right = -11.9999 offset_bottom = -12.0 -__meta__ = { -"_edit_lock_": true, -"_edit_use_anchors_": false -} +grow_horizontal = 2 +grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="Control"] +layout_mode = 0 offset_right = 269.0 offset_bottom = 330.0 -custom_constants/separation = 30 -script = ExtResource( 2 ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("2") [node name="SaveLoad" type="GridContainer" parent="Control/VBoxContainer"] -offset_right = 269.0 -offset_bottom = 78.0 -custom_constants/vseparation = 8 -custom_constants/hseparation = 8 +layout_mode = 2 columns = 2 [node name="SaveConfigFile" type="Button" parent="Control/VBoxContainer/SaveLoad"] -offset_right = 130.0 -offset_bottom = 35.0 -rect_min_size = Vector2(0, 35) +layout_mode = 2 size_flags_horizontal = 3 -text = "Save as ConfigFile" -script = ExtResource( 4 ) +text = "Save ConfigFile" +script = ExtResource("4") game_node = NodePath("../../../../Game") player_node = NodePath("../../../../Game/Player") [node name="LoadConfigFile" type="Button" parent="Control/VBoxContainer/SaveLoad"] -offset_left = 138.0 -offset_right = 268.0 -offset_bottom = 35.0 -rect_min_size = Vector2(0, 35) +layout_mode = 2 size_flags_horizontal = 3 -text = "Load as ConfigFile" -script = ExtResource( 4 ) +text = "Load ConfigFile" +script = ExtResource("4") game_node = NodePath("../../../../Game") player_node = NodePath("../../../../Game/Player") [node name="SaveJSON" type="Button" parent="Control/VBoxContainer/SaveLoad"] -offset_top = 43.0 -offset_right = 130.0 -offset_bottom = 78.0 -rect_min_size = Vector2(0, 35) +layout_mode = 2 size_flags_horizontal = 3 -text = "Save as JSON" -script = ExtResource( 3 ) +text = "Save JSON" +script = ExtResource("3") game_node = NodePath("../../../../Game") player_node = NodePath("../../../../Game/Player") [node name="LoadJSON" type="Button" parent="Control/VBoxContainer/SaveLoad"] -offset_left = 138.0 -offset_top = 43.0 -offset_right = 268.0 -offset_bottom = 78.0 -rect_min_size = Vector2(0, 35) +layout_mode = 2 size_flags_horizontal = 3 -text = "Load as JSON" -script = ExtResource( 3 ) +text = "Load JSON" +script = ExtResource("3") game_node = NodePath("../../../../Game") player_node = NodePath("../../../../Game/Player") [node name="OpenUserDataFolder" type="Button" parent="Control/VBoxContainer"] -offset_top = 108.0 -offset_right = 269.0 -offset_bottom = 143.0 -rect_min_size = Vector2(0, 35) -hint_tooltip = "Click this button to check the saved files using the operating system's file manager." +layout_mode = 2 +tooltip_text = "Click this button to check the saved files using the operating system's file manager." text = "Open User Data Folder" [node name="RichTextLabel" type="RichTextLabel" parent="Control/VBoxContainer"] -offset_top = 173.0 -offset_right = 269.0 -offset_bottom = 453.0 -rect_min_size = Vector2(0, 280) -custom_constants/line_separation = 4 +layout_mode = 2 +size_flags_vertical = 3 bbcode_enabled = true -bbcode_text = "Use the arrow keys or controller to move the player. - -Use the save and load buttons to save/load the game with the respective format (each format is its own savegame)." text = "Use the arrow keys or controller to move the player. Use the save and load buttons to save/load the game with the respective format (each format is its own savegame)." diff --git a/loading/serialization/save_load_config_file.gd b/loading/serialization/save_load_config_file.gd index 0be06948..9774ca20 100644 --- a/loading/serialization/save_load_config_file.gd +++ b/loading/serialization/save_load_config_file.gd @@ -1,24 +1,28 @@ extends Button # This script shows how to save data using Godot's custom ConfigFile format. -# ConfigFile can store any Godot type natively. +# ConfigFile can store any Variant type except Signal or Callable. +# It can even store Objects, but be extra careful where you deserialize them +# from, because they can include (potentially malicious) scripts. -# The root game node (so we can get and instance enemies). -@export var game_node: NodePath -# The player node (so we can set/get its health and position). -@export var player_node: NodePath const SAVE_PATH = "user://save_config_file.ini" +## The root game node (so we can get and instance enemies). +@export var game_node: NodePath +## The player node (so we can set/get its health and position). +@export var player_node: NodePath + func save_game(): - var config = ConfigFile.new() + var config := ConfigFile.new() - var player = get_node(player_node) + var player := get_node(player_node) as Player config.set_value("player", "position", player.position) config.set_value("player", "health", player.health) + config.set_value("player", "rotation", player.sprite.rotation) - var enemies = [] - for enemy in get_tree().get_nodes_in_group("enemy"): + var enemies := [] + for enemy in get_tree().get_nodes_in_group(&"enemy"): enemies.push_back({ position = enemy.position, }) @@ -26,27 +30,25 @@ func save_game(): config.save(SAVE_PATH) - get_node(^"../LoadConfigFile").disabled = false + (get_node(^"../LoadConfigFile") as Button).disabled = false -# `load()` is reserved. func load_game(): - var config = ConfigFile.new() + var config := ConfigFile.new() config.load(SAVE_PATH) - var player = get_node(player_node) + var player := get_node(player_node) as Player player.position = config.get_value("player", "position") player.health = config.get_value("player", "health") + player.sprite.rotation = config.get_value("player", "rotation") - # Remove existing enemies and add new ones. - for enemy in get_tree().get_nodes_in_group("enemy"): - enemy.queue_free() + # Remove existing enemies before adding new ones. + get_tree().call_group("enemy", "queue_free") var enemies = config.get_value("enemies", "enemies") - # Ensure the node structure is the same when loading. var game = get_node(game_node) for enemy_config in enemies: - var enemy = preload("res://enemy.tscn").instantiate() + var enemy := preload("res://enemy.tscn").instantiate() as Enemy enemy.position = enemy_config.position game.add_child(enemy) diff --git a/loading/serialization/save_load_json.gd b/loading/serialization/save_load_json.gd index d7cf318b..4e9fbab6 100644 --- a/loading/serialization/save_load_json.gd +++ b/loading/serialization/save_load_json.gd @@ -2,34 +2,36 @@ extends Button # This script shows how to save data using the JSON file format. # JSON is a widely used file format, but not all Godot types can be # stored natively. For example, integers get converted into doubles, -# and to store Vector2 and other non-JSON types you need `var2str()`. +# and to store Vector2 and other non-JSON types you need to convert +# them, such as to a String using var_to_str. -# The root game node (so we can get and instance enemies). + +## The root game node (so we can get and instance enemies). @export var game_node: NodePath -# The player node (so we can set/get its health and position). +## The player node (so we can set/get its health and position). @export var player_node: NodePath const SAVE_PATH = "user://save_json.json" func save_game(): - var file = File.new() - file.open(SAVE_PATH, File.WRITE) + var file := FileAccess.open(SAVE_PATH, FileAccess.WRITE) var player = get_node(player_node) - # JSON doesn't support complex types such as Vector2. - # `var2str()` can be used to convert any Variant to a String. + # JSON doesn't support many of Godot's types such as Vector2. + # var_to_str can be used to convert any Variant to a String. var save_dict = { player = { - position = var2str(player.position), - health = var2str(player.health), + position = var_to_str(player.position), + health = var_to_str(player.health), + rotation = var_to_str(player.sprite.rotation) }, enemies = [] } - for enemy in get_tree().get_nodes_in_group("enemy"): + for enemy in get_tree().get_nodes_in_group(&"enemy"): save_dict.enemies.push_back({ - position = var2str(enemy.position), + position = var_to_str(enemy.position), }) file.store_line(JSON.new().stringify(save_dict)) @@ -37,28 +39,26 @@ func save_game(): get_node(^"../LoadJSON").disabled = false -# `load()` is reserved. func load_game(): - var file = File.new() - file.open(SAVE_PATH, File.READ) - var json = JSON.new() + var file := FileAccess.open(SAVE_PATH, FileAccess.READ) + var json := JSON.new() json.parse(file.get_line()) - var save_dict = json.get_data() + var save_dict := json.get_data() as Dictionary - var player = get_node(player_node) - # JSON doesn't support complex types such as Vector2. - # `str2var()` can be used to convert a String to the corresponding Variant. - player.position = str2var(save_dict.player.position) - player.health = str2var(save_dict.player.health) + var player := get_node(player_node) as Player + # JSON doesn't support many of Godot's types such as Vector2. + # str_to_var can be used to convert a String to the corresponding Variant. + player.position = str_to_var(save_dict.player.position) + player.health = str_to_var(save_dict.player.health) + player.sprite.rotation = str_to_var(save_dict.player.rotation) - # Remove existing enemies and add new ones. - for enemy in get_tree().get_nodes_in_group("enemy"): - enemy.queue_free() + # Remove existing enemies before adding new ones. + get_tree().call_group("enemy", "queue_free") # Ensure the node structure is the same when loading. - var game = get_node(game_node) + var game := get_node(game_node) for enemy_config in save_dict.enemies: var enemy = preload("res://enemy.tscn").instantiate() - enemy.position = str2var(enemy_config.position) + enemy.position = str_to_var(enemy_config.position) game.add_child(enemy) diff --git a/loading/serialization/screenshots/save_load.png b/loading/serialization/screenshots/save_load.png index 7e74290c..7a2b0bad 100644 Binary files a/loading/serialization/screenshots/save_load.png and b/loading/serialization/screenshots/save_load.png differ diff --git a/loading/serialization/sea_turtle.png b/loading/serialization/sea_turtle.png new file mode 100644 index 00000000..7bdf3e1f Binary files /dev/null and b/loading/serialization/sea_turtle.png differ diff --git a/loading/serialization/sea_turtle.png.import b/loading/serialization/sea_turtle.png.import new file mode 100644 index 00000000..57c8ac22 --- /dev/null +++ b/loading/serialization/sea_turtle.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dpm1oolm8wr02" +path="res://.godot/imported/sea_turtle.png-2ef6b4a0ba2e0c29cbed022d80f0e8be.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sea_turtle.png" +dest_files=["res://.godot/imported/sea_turtle.png-2ef6b4a0ba2e0c29cbed022d80f0e8be.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/threads/README.md b/loading/threads/README.md index d5a90616..affe0d72 100644 --- a/loading/threads/README.md +++ b/loading/threads/README.md @@ -4,7 +4,7 @@ An example using a thread to load an image. Language: GDScript -Renderer: Vulkan Mobile +Renderer: Mobile Check out this demo on the asset library: https://godotengine.org/asset-library/asset/144 diff --git a/loading/threads/icon.png b/loading/threads/icon.png new file mode 100644 index 00000000..612ea026 Binary files /dev/null and b/loading/threads/icon.png differ diff --git a/loading/threads/icon.png.import b/loading/threads/icon.png.import new file mode 100644 index 00000000..11b64b41 --- /dev/null +++ b/loading/threads/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://p4sshn67o4v6" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/threads/project.godot b/loading/threads/project.godot index 48e19722..08ad356b 100644 --- a/loading/threads/project.godot +++ b/loading/threads/project.godot @@ -14,7 +14,13 @@ config/name="Loading in a Thread" config/description="An example using a thread to load an image." run/main_scene="res://thread.tscn" config/features=PackedStringArray("4.0") +run/low_processor_mode=true +config/icon="res://icon.png" + +[display] + +window/vsync/vsync_mode=0 [rendering] -vulkan/rendering/back_end=1 +renderer/rendering_method="mobile" diff --git a/loading/threads/screenshots/load_in_thread.png b/loading/threads/screenshots/load_in_thread.png index bf1bfc55..6656369e 100644 Binary files a/loading/threads/screenshots/load_in_thread.png and b/loading/threads/screenshots/load_in_thread.png differ diff --git a/loading/threads/thread.gd b/loading/threads/thread.gd index 4d9a6452..c4be98a1 100644 --- a/loading/threads/thread.gd +++ b/loading/threads/thread.gd @@ -1,7 +1,9 @@ -extends Node2D +extends Control + var thread: Thread + func _on_load_pressed(): if is_instance_valid(thread) and thread.is_started(): # If a thread is already running, let it finish before we start another. @@ -26,9 +28,9 @@ func _bg_load_done(): # Wait for the thread to complete, and get the returned value. var tex = thread.wait_to_finish() print("THREAD FINISHED!") - $Sprite2D.set_texture(tex) + $TextureRect.texture = tex # We're done with the thread now, so we can free it. - thread = null # Threads are reference counted, so this is how we free it. + thread = null # Threads are reference counted, so this is how we free them. func _exit_tree(): diff --git a/loading/threads/thread.tscn b/loading/threads/thread.tscn index c4c46682..be538aa1 100644 --- a/loading/threads/thread.tscn +++ b/loading/threads/thread.tscn @@ -2,23 +2,35 @@ [ext_resource type="Script" path="res://thread.gd" id="1"] -[node name="Thread" type="Node2D"] +[node name="Thread" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 script = ExtResource("1") [node name="Load" type="Button" parent="."] -offset_left = 432.0 -offset_top = 82.0 -offset_right = 560.0 -offset_bottom = 114.0 +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.4 +anchor_top = 0.15 +anchor_right = 0.6 +anchor_bottom = 0.2 size_flags_horizontal = 2 size_flags_vertical = 2 text = "Load in Thread" -[node name="Sprite2D" type="Sprite2D" parent="."] -position = Vector2(494, 336) - -[node name="Camera2D" type="Camera2D" parent="."] -offset = Vector2(512, 300) -current = true +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +stretch_mode = 5 [connection signal="pressed" from="Load" to="." method="_on_load_pressed"]