diff --git a/classes/class_node.rst b/classes/class_node.rst index fa5e0db93..dea9d055d 100644 --- a/classes/class_node.rst +++ b/classes/class_node.rst @@ -43,7 +43,7 @@ Finally, when a node is freed with :ref:`Object.free` Tutorials --------- -- :doc:`../getting_started/step_by_step/scenes_and_nodes` +- :doc:`../getting_started/step_by_step/nodes_and_scenes` Properties ---------- diff --git a/classes/class_script.rst b/classes/class_script.rst index 6eb6eb34a..bc1535fbd 100644 --- a/classes/class_script.rst +++ b/classes/class_script.rst @@ -25,7 +25,7 @@ The ``new`` method of a script subclass creates a new instance. :ref:`Object.set Tutorials --------- -- :doc:`../getting_started/step_by_step/scripting` +- :doc:`../getting_started/step_by_step/scripting_first_script` Properties ---------- diff --git a/community/contributing/editor_and_docs_localization.rst b/community/contributing/editor_and_docs_localization.rst index 1b3e2db34..e06a2e470 100644 --- a/community/contributing/editor_and_docs_localization.rst +++ b/community/contributing/editor_and_docs_localization.rst @@ -171,8 +171,8 @@ translating. a page that you want to translate, and then translate all the strings with the same source string location while comparing with the online version of that page in English. An example of source string location could be - ``getting_started/step_by_step/scenes_and_nodes.rst`` for the - page :ref:`doc_scenes_and_nodes`. + ``getting_started/step_by_step/nodes_and_scenes.rst`` for the + page :ref:`doc_nodes_and_scenes`. - The class reference's translation template is generated from the source XML files in **alphabetical order**, which is also the same as the order of the table of contents for the online version. You can therefore locate the source @@ -184,7 +184,7 @@ translating. A handy tool to locate specific pages/classes is to use Weblate's advanced search feature, and especially the "Location strings" query (which can also be -used with the ``location:`` token, e.g. ``location:scenes_and_nodes.rst``): +used with the ``location:`` token, e.g. ``location:nodes_and_scenes.rst``): .. image:: img/l10n_05_search_location.png @@ -194,9 +194,9 @@ used with the ``location:`` token, e.g. ``location:scenes_and_nodes.rst``): When a given source string is used in multiple source locations, they will all be concatenated into one. For example, the above - ``location:scenes_and_nodes.rst`` query would land first on the + ``location:nodes_and_scenes.rst`` query would land first on the "Introduction" source string which is used in dozens of pages, including - some that come before ``scenes_and_nodes.rst`` in the template. Clicking the + some that come before ``nodes_and_scenes.rst`` in the template. Clicking the "Next" button then brings us to the "Scene and nodes" title string displayed above. So it may happen that a given paragraph or section title is not at the diff --git a/getting_started/introduction/img/editor_ui_intro_dock_filesystem.png b/getting_started/introduction/img/editor_ui_intro_dock_filesystem.png new file mode 100644 index 000000000..bdf409469 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_dock_filesystem.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_dock_inspector.png b/getting_started/introduction/img/editor_ui_intro_dock_inspector.png new file mode 100644 index 000000000..902f1a18b Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_dock_inspector.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_02_toolbar.png b/getting_started/introduction/img/editor_ui_intro_editor_02_toolbar.png new file mode 100644 index 000000000..0005769fc Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_02_toolbar.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_03_animation_player.png b/getting_started/introduction/img/editor_ui_intro_editor_03_animation_player.png new file mode 100644 index 000000000..60ef080ab Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_03_animation_player.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_04_2d_workspace.png b/getting_started/introduction/img/editor_ui_intro_editor_04_2d_workspace.png new file mode 100644 index 000000000..0deae9729 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_04_2d_workspace.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_05_3d_workspace.png b/getting_started/introduction/img/editor_ui_intro_editor_05_3d_workspace.png new file mode 100644 index 000000000..4a07c7b13 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_05_3d_workspace.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_06_3d_workspace.png b/getting_started/introduction/img/editor_ui_intro_editor_06_3d_workspace.png new file mode 100644 index 000000000..0410960b4 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_06_3d_workspace.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_06_script_workspace_expanded.png b/getting_started/introduction/img/editor_ui_intro_editor_06_script_workspace_expanded.png new file mode 100644 index 000000000..ee051fbe4 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_06_script_workspace_expanded.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_editor_interface_overview.png b/getting_started/introduction/img/editor_ui_intro_editor_interface_overview.png new file mode 100644 index 000000000..c0e87fa79 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_editor_interface_overview.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_script_class_documentation.png b/getting_started/introduction/img/editor_ui_intro_script_class_documentation.png new file mode 100644 index 000000000..1592cde02 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_script_class_documentation.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_script_search_documentation.png b/getting_started/introduction/img/editor_ui_intro_script_search_documentation.png new file mode 100644 index 000000000..b5d19a172 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_script_search_documentation.png differ diff --git a/getting_started/introduction/img/editor_ui_intro_script_search_help_window.png b/getting_started/introduction/img/editor_ui_intro_script_search_help_window.png new file mode 100644 index 000000000..c4a7a5c16 Binary files /dev/null and b/getting_started/introduction/img/editor_ui_intro_script_search_help_window.png differ diff --git a/getting_started/introduction/key_concepts_overview.rst b/getting_started/introduction/key_concepts_overview.rst index c97e8023d..20716f013 100644 --- a/getting_started/introduction/key_concepts_overview.rst +++ b/getting_started/introduction/key_concepts_overview.rst @@ -76,7 +76,7 @@ flexibility in how you structure your scenes. .. image:: img/key_concepts_signals.png .. note:: Signals are Godot's version of the *observer* pattern. You can read - more about the observer pattern here: + more about it here: https://gameprogrammingpatterns.com/observer.html For example, buttons emit a signal when pressed. You can connect to this signal diff --git a/getting_started/step_by_step/img/instancing.png b/getting_started/step_by_step/img/instancing.png deleted file mode 100644 index 563a98baf..000000000 Binary files a/getting_started/step_by_step/img/instancing.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_ball_duplicated.png b/getting_started/step_by_step/img/instancing_ball_duplicated.png new file mode 100644 index 000000000..b446f93cd Binary files /dev/null and b/getting_started/step_by_step/img/instancing_ball_duplicated.png differ diff --git a/getting_started/step_by_step/img/instancing_ball_instanced.png b/getting_started/step_by_step/img/instancing_ball_instanced.png new file mode 100644 index 000000000..1b73ca811 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_ball_instanced.png differ diff --git a/getting_started/step_by_step/img/instancing_ball_instances_example.png b/getting_started/step_by_step/img/instancing_ball_instances_example.png new file mode 100644 index 000000000..61796916e Binary files /dev/null and b/getting_started/step_by_step/img/instancing_ball_instances_example.png differ diff --git a/getting_started/step_by_step/img/instancing_ball_moved.png b/getting_started/step_by_step/img/instancing_ball_moved.png new file mode 100644 index 000000000..80ee2d534 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_ball_moved.png differ diff --git a/getting_started/step_by_step/img/instancing_ball_scene.png b/getting_started/step_by_step/img/instancing_ball_scene.png new file mode 100644 index 000000000..908773942 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_ball_scene.png differ diff --git a/getting_started/step_by_step/img/instancing_ballscene.png b/getting_started/step_by_step/img/instancing_ballscene.png deleted file mode 100644 index 8234da0f6..000000000 Binary files a/getting_started/step_by_step/img/instancing_ballscene.png and /dev/null differ diff --git a/getting_started/step_by_step/img/openworld_instancing.png b/getting_started/step_by_step/img/instancing_diagram_open_world.png similarity index 100% rename from getting_started/step_by_step/img/openworld_instancing.png rename to getting_started/step_by_step/img/instancing_diagram_open_world.png diff --git a/getting_started/step_by_step/img/shooter_instancing.png b/getting_started/step_by_step/img/instancing_diagram_shooter.png similarity index 100% rename from getting_started/step_by_step/img/shooter_instancing.png rename to getting_started/step_by_step/img/instancing_diagram_shooter.png diff --git a/getting_started/step_by_step/img/instancing_import.png b/getting_started/step_by_step/img/instancing_import.png deleted file mode 100644 index 61d462262..000000000 Binary files a/getting_started/step_by_step/img/instancing_import.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_import_and_edit_button.png b/getting_started/step_by_step/img/instancing_import_and_edit_button.png new file mode 100644 index 000000000..ccd476897 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_import_and_edit_button.png differ diff --git a/getting_started/step_by_step/img/instancing_import_browse.png b/getting_started/step_by_step/img/instancing_import_browse.png new file mode 100644 index 000000000..f6e8ac2a6 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_import_browse.png differ diff --git a/getting_started/step_by_step/img/instancing_import_button.png b/getting_started/step_by_step/img/instancing_import_button.png new file mode 100644 index 000000000..d4d157bb4 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_import_button.png differ diff --git a/getting_started/step_by_step/img/instancing_import_project_file.png b/getting_started/step_by_step/img/instancing_import_project_file.png new file mode 100644 index 000000000..a5ca8d6fc Binary files /dev/null and b/getting_started/step_by_step/img/instancing_import_project_file.png differ diff --git a/getting_started/step_by_step/img/instancing_instance_child_window.png b/getting_started/step_by_step/img/instancing_instance_child_window.png new file mode 100644 index 000000000..777ecdbca Binary files /dev/null and b/getting_started/step_by_step/img/instancing_instance_child_window.png differ diff --git a/getting_started/step_by_step/img/instancing_linkbutton.png b/getting_started/step_by_step/img/instancing_linkbutton.png deleted file mode 100644 index 12327aed4..000000000 Binary files a/getting_started/step_by_step/img/instancing_linkbutton.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_main_scene.png b/getting_started/step_by_step/img/instancing_main_scene.png new file mode 100644 index 000000000..5c129113d Binary files /dev/null and b/getting_started/step_by_step/img/instancing_main_scene.png differ diff --git a/getting_started/step_by_step/img/instancing_main_scene_with_balls.png b/getting_started/step_by_step/img/instancing_main_scene_with_balls.png new file mode 100644 index 000000000..ccba73633 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_main_scene_with_balls.png differ diff --git a/getting_started/step_by_step/img/instancing_mainroot.png b/getting_started/step_by_step/img/instancing_mainroot.png deleted file mode 100644 index 321abbf8c..000000000 Binary files a/getting_started/step_by_step/img/instancing_mainroot.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_mainscene.png b/getting_started/step_by_step/img/instancing_mainscene.png deleted file mode 100644 index f63e4a0c5..000000000 Binary files a/getting_started/step_by_step/img/instancing_mainscene.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_multiball.gif b/getting_started/step_by_step/img/instancing_multiball.gif deleted file mode 100644 index 8e1cc1bf4..000000000 Binary files a/getting_started/step_by_step/img/instancing_multiball.gif and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_multiball.png b/getting_started/step_by_step/img/instancing_multiball.png deleted file mode 100644 index 328adce21..000000000 Binary files a/getting_started/step_by_step/img/instancing_multiball.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_physics_material_expand.png b/getting_started/step_by_step/img/instancing_physics_material_expand.png new file mode 100644 index 000000000..2d3a0be23 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_physics_material_expand.png differ diff --git a/getting_started/step_by_step/img/instancing_physicsmat2.png b/getting_started/step_by_step/img/instancing_physicsmat2.png deleted file mode 100644 index 709892045..000000000 Binary files a/getting_started/step_by_step/img/instancing_physicsmat2.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_placeball.png b/getting_started/step_by_step/img/instancing_placeball.png deleted file mode 100644 index 3a9f0cab1..000000000 Binary files a/getting_started/step_by_step/img/instancing_placeball.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_playbutton.png b/getting_started/step_by_step/img/instancing_playbutton.png deleted file mode 100644 index 3ad0de201..000000000 Binary files a/getting_started/step_by_step/img/instancing_playbutton.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_property.png b/getting_started/step_by_step/img/instancing_property.png deleted file mode 100644 index 7908f33e9..000000000 Binary files a/getting_started/step_by_step/img/instancing_property.png and /dev/null differ diff --git a/getting_started/step_by_step/img/instancing_property_bounce_updated.png b/getting_started/step_by_step/img/instancing_property_bounce_updated.png new file mode 100644 index 000000000..f1ab9d917 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_property_bounce_updated.png differ diff --git a/getting_started/step_by_step/img/instancing_property_gravity_scale.png b/getting_started/step_by_step/img/instancing_property_gravity_scale.png new file mode 100644 index 000000000..b88b7314a Binary files /dev/null and b/getting_started/step_by_step/img/instancing_property_gravity_scale.png differ diff --git a/getting_started/step_by_step/img/instancing_property_revert_icon.png b/getting_started/step_by_step/img/instancing_property_revert_icon.png new file mode 100644 index 000000000..a9eb6989d Binary files /dev/null and b/getting_started/step_by_step/img/instancing_property_revert_icon.png differ diff --git a/getting_started/step_by_step/img/instancing_scene_link_button.png b/getting_started/step_by_step/img/instancing_scene_link_button.png new file mode 100644 index 000000000..96ba8b53e Binary files /dev/null and b/getting_started/step_by_step/img/instancing_scene_link_button.png differ diff --git a/getting_started/step_by_step/img/instancing_scene_tabs.png b/getting_started/step_by_step/img/instancing_scene_tabs.png new file mode 100644 index 000000000..e5555acf0 Binary files /dev/null and b/getting_started/step_by_step/img/instancing_scene_tabs.png differ diff --git a/getting_started/step_by_step/img/instancingpre.png b/getting_started/step_by_step/img/instancingpre.png deleted file mode 100644 index a63a3483d..000000000 Binary files a/getting_started/step_by_step/img/instancingpre.png and /dev/null differ diff --git a/getting_started/step_by_step/img/node_classes.png b/getting_started/step_by_step/img/node_classes.png deleted file mode 100644 index 1be0efcf2..000000000 Binary files a/getting_started/step_by_step/img/node_classes.png and /dev/null differ diff --git a/getting_started/step_by_step/img/node_search_label.png b/getting_started/step_by_step/img/node_search_label.png deleted file mode 100644 index 766f7a5d5..000000000 Binary files a/getting_started/step_by_step/img/node_search_label.png and /dev/null differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_01_empty_editor.png b/getting_started/step_by_step/img/nodes_and_scenes_01_empty_editor.png new file mode 100644 index 000000000..55967e2ae Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_01_empty_editor.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_02_scene_dock.png b/getting_started/step_by_step/img/nodes_and_scenes_02_scene_dock.png new file mode 100644 index 000000000..4a0c9c5eb Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_02_scene_dock.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_03_create_node_window.png b/getting_started/step_by_step/img/nodes_and_scenes_03_create_node_window.png new file mode 100644 index 000000000..b21fcb2b8 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_03_create_node_window.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_04_create_label_window.png b/getting_started/step_by_step/img/nodes_and_scenes_04_create_label_window.png new file mode 100644 index 000000000..ee5490720 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_04_create_label_window.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_05_editor_with_label.png b/getting_started/step_by_step/img/nodes_and_scenes_05_editor_with_label.png new file mode 100644 index 000000000..d9f70d8dd Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_05_editor_with_label.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_06_label_text.png b/getting_started/step_by_step/img/nodes_and_scenes_06_label_text.png new file mode 100644 index 000000000..01dec43a9 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_06_label_text.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_07_move_tool.png b/getting_started/step_by_step/img/nodes_and_scenes_07_move_tool.png new file mode 100644 index 000000000..a707e64b4 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_07_move_tool.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_08_hello_world_text.png b/getting_started/step_by_step/img/nodes_and_scenes_08_hello_world_text.png new file mode 100644 index 000000000..60be6f4cd Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_08_hello_world_text.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_09_play_scene_button.png b/getting_started/step_by_step/img/nodes_and_scenes_09_play_scene_button.png new file mode 100644 index 000000000..0dcd456b2 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_09_play_scene_button.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_10_save_scene_popup.png b/getting_started/step_by_step/img/nodes_and_scenes_10_save_scene_popup.png new file mode 100644 index 000000000..f77fd6c4c Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_10_save_scene_popup.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_11_save_scene_as.png b/getting_started/step_by_step/img/nodes_and_scenes_11_save_scene_as.png new file mode 100644 index 000000000..338c086fb Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_11_save_scene_as.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_12_final_result.png b/getting_started/step_by_step/img/nodes_and_scenes_12_final_result.png new file mode 100644 index 000000000..b2bad71a8 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_12_final_result.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_13_play_button.png b/getting_started/step_by_step/img/nodes_and_scenes_13_play_button.png new file mode 100644 index 000000000..8a789a934 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_13_play_button.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_14_main_scene_popup.png b/getting_started/step_by_step/img/nodes_and_scenes_14_main_scene_popup.png new file mode 100644 index 000000000..35d39da7b Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_14_main_scene_popup.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_15_select_main_scene.png b/getting_started/step_by_step/img/nodes_and_scenes_15_select_main_scene.png new file mode 100644 index 000000000..abfd52ded Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_15_select_main_scene.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_3d_scene_example.png b/getting_started/step_by_step/img/nodes_and_scenes_3d_scene_example.png new file mode 100644 index 000000000..8df12a3fd Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_3d_scene_example.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_character_nodes.png b/getting_started/step_by_step/img/nodes_and_scenes_character_nodes.png new file mode 100644 index 000000000..e0d7bc0a7 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_character_nodes.png differ diff --git a/getting_started/step_by_step/img/nodes_and_scenes_nodes.png b/getting_started/step_by_step/img/nodes_and_scenes_nodes.png new file mode 100644 index 000000000..d8d3a4226 Binary files /dev/null and b/getting_started/step_by_step/img/nodes_and_scenes_nodes.png differ diff --git a/getting_started/step_by_step/img/scripting_camera_shake.gif b/getting_started/step_by_step/img/scripting_camera_shake.gif new file mode 100644 index 000000000..7a9d845c2 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_camera_shake.gif differ diff --git a/getting_started/step_by_step/img/scripting_cpp.png b/getting_started/step_by_step/img/scripting_cpp.png new file mode 100644 index 000000000..32db3a051 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_cpp.png differ diff --git a/getting_started/step_by_step/img/scripting_csharp.png b/getting_started/step_by_step/img/scripting_csharp.png new file mode 100644 index 000000000..567c9cb74 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_csharp.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_add_sprite_node.png b/getting_started/step_by_step/img/scripting_first_script_add_sprite_node.png new file mode 100644 index 000000000..389cadbd2 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_add_sprite_node.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_attach_node_script.png b/getting_started/step_by_step/img/scripting_first_script_attach_node_script.png new file mode 100644 index 000000000..48629fd8a Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_attach_node_script.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_attach_script.png b/getting_started/step_by_step/img/scripting_first_script_attach_script.png new file mode 100644 index 000000000..1c5ec73ec Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_attach_script.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_centering_sprite.png b/getting_started/step_by_step/img/scripting_first_script_centering_sprite.png new file mode 100644 index 000000000..6b521a480 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_centering_sprite.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_click_other_node.png b/getting_started/step_by_step/img/scripting_first_script_click_other_node.png new file mode 100644 index 000000000..55673271e Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_click_other_node.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_dragging_sprite.png b/getting_started/step_by_step/img/scripting_first_script_dragging_sprite.png new file mode 100644 index 000000000..ffa9dee40 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_dragging_sprite.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_godot_turning_in_place.gif b/getting_started/step_by_step/img/scripting_first_script_godot_turning_in_place.gif new file mode 100644 index 000000000..50063c09a Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_godot_turning_in_place.gif differ diff --git a/getting_started/step_by_step/img/scripting_first_script_moving_with_input.gif b/getting_started/step_by_step/img/scripting_first_script_moving_with_input.gif new file mode 100644 index 000000000..9c6697ee9 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_moving_with_input.gif differ diff --git a/getting_started/step_by_step/img/scripting_first_script_print_hello_world.png b/getting_started/step_by_step/img/scripting_first_script_print_hello_world.png new file mode 100644 index 000000000..f8c1ce262 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_print_hello_world.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_property_tooltips.png b/getting_started/step_by_step/img/scripting_first_script_property_tooltips.png new file mode 100644 index 000000000..faf727830 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_property_tooltips.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_rotating_godot.gif b/getting_started/step_by_step/img/scripting_first_script_rotating_godot.gif new file mode 100644 index 000000000..f431f844a Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_rotating_godot.gif differ diff --git a/getting_started/step_by_step/img/scripting_first_script_scene_tree.png b/getting_started/step_by_step/img/scripting_first_script_scene_tree.png new file mode 100644 index 000000000..b0c61f956 Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_scene_tree.png differ diff --git a/getting_started/step_by_step/img/scripting_first_script_setting_texture.png b/getting_started/step_by_step/img/scripting_first_script_setting_texture.png new file mode 100644 index 000000000..6f1a6648b Binary files /dev/null and b/getting_started/step_by_step/img/scripting_first_script_setting_texture.png differ diff --git a/getting_started/step_by_step/img/scripting_gdscript.png b/getting_started/step_by_step/img/scripting_gdscript.png new file mode 100644 index 000000000..21f3a0f4e Binary files /dev/null and b/getting_started/step_by_step/img/scripting_gdscript.png differ diff --git a/getting_started/step_by_step/img/scripting_visualscript.png b/getting_started/step_by_step/img/scripting_visualscript.png new file mode 100644 index 000000000..f34df6c8f Binary files /dev/null and b/getting_started/step_by_step/img/scripting_visualscript.png differ diff --git a/getting_started/step_by_step/img/signals_01_new_scene.png b/getting_started/step_by_step/img/signals_01_new_scene.png new file mode 100644 index 000000000..36d6915fb Binary files /dev/null and b/getting_started/step_by_step/img/signals_01_new_scene.png differ diff --git a/getting_started/step_by_step/img/signals_02_2d_scene.png b/getting_started/step_by_step/img/signals_02_2d_scene.png new file mode 100644 index 000000000..ef9c0fc07 Binary files /dev/null and b/getting_started/step_by_step/img/signals_02_2d_scene.png differ diff --git a/getting_started/step_by_step/img/signals_03_dragging_scene.png b/getting_started/step_by_step/img/signals_03_dragging_scene.png new file mode 100644 index 000000000..307f19f2d Binary files /dev/null and b/getting_started/step_by_step/img/signals_03_dragging_scene.png differ diff --git a/getting_started/step_by_step/img/signals_04_add_child_node.png b/getting_started/step_by_step/img/signals_04_add_child_node.png new file mode 100644 index 000000000..9b0e833a6 Binary files /dev/null and b/getting_started/step_by_step/img/signals_04_add_child_node.png differ diff --git a/getting_started/step_by_step/img/signals_05_add_button.png b/getting_started/step_by_step/img/signals_05_add_button.png new file mode 100644 index 000000000..62865c133 Binary files /dev/null and b/getting_started/step_by_step/img/signals_05_add_button.png differ diff --git a/getting_started/step_by_step/img/signals_06_drag_button.png b/getting_started/step_by_step/img/signals_06_drag_button.png new file mode 100644 index 000000000..aa0e2a2a2 Binary files /dev/null and b/getting_started/step_by_step/img/signals_06_drag_button.png differ diff --git a/getting_started/step_by_step/img/signals_07_select_tool.png b/getting_started/step_by_step/img/signals_07_select_tool.png new file mode 100644 index 000000000..21af81639 Binary files /dev/null and b/getting_started/step_by_step/img/signals_07_select_tool.png differ diff --git a/getting_started/step_by_step/img/signals_08_toggle_motion_text.png b/getting_started/step_by_step/img/signals_08_toggle_motion_text.png new file mode 100644 index 000000000..295289b0b Binary files /dev/null and b/getting_started/step_by_step/img/signals_08_toggle_motion_text.png differ diff --git a/getting_started/step_by_step/img/signals_09_scene_setup.png b/getting_started/step_by_step/img/signals_09_scene_setup.png new file mode 100644 index 000000000..908b38c5d Binary files /dev/null and b/getting_started/step_by_step/img/signals_09_scene_setup.png differ diff --git a/getting_started/step_by_step/img/signals_10_node_dock.png b/getting_started/step_by_step/img/signals_10_node_dock.png new file mode 100644 index 000000000..70df7270f Binary files /dev/null and b/getting_started/step_by_step/img/signals_10_node_dock.png differ diff --git a/getting_started/step_by_step/img/signals_11_pressed_signals.png b/getting_started/step_by_step/img/signals_11_pressed_signals.png new file mode 100644 index 000000000..5dfde3ed4 Binary files /dev/null and b/getting_started/step_by_step/img/signals_11_pressed_signals.png differ diff --git a/getting_started/step_by_step/img/signals_12_node_connection.png b/getting_started/step_by_step/img/signals_12_node_connection.png new file mode 100644 index 000000000..2192babd9 Binary files /dev/null and b/getting_started/step_by_step/img/signals_12_node_connection.png differ diff --git a/getting_started/step_by_step/img/signals_13_signals_connection_icon.png b/getting_started/step_by_step/img/signals_13_signals_connection_icon.png new file mode 100644 index 000000000..926a46b72 Binary files /dev/null and b/getting_started/step_by_step/img/signals_13_signals_connection_icon.png differ diff --git a/getting_started/step_by_step/img/signals_14_signals_connection_info.png b/getting_started/step_by_step/img/signals_14_signals_connection_info.png new file mode 100644 index 000000000..9bc5f0106 Binary files /dev/null and b/getting_started/step_by_step/img/signals_14_signals_connection_info.png differ diff --git a/getting_started/step_by_step/img/signals_15_scene_tree.png b/getting_started/step_by_step/img/signals_15_scene_tree.png new file mode 100644 index 000000000..a635c7646 Binary files /dev/null and b/getting_started/step_by_step/img/signals_15_scene_tree.png differ diff --git a/getting_started/step_by_step/img/signals_16_click_script.png b/getting_started/step_by_step/img/signals_16_click_script.png new file mode 100644 index 000000000..f1929b546 Binary files /dev/null and b/getting_started/step_by_step/img/signals_16_click_script.png differ diff --git a/getting_started/step_by_step/img/signals_17_custom_signal.png b/getting_started/step_by_step/img/signals_17_custom_signal.png new file mode 100644 index 000000000..8e91bcea0 Binary files /dev/null and b/getting_started/step_by_step/img/signals_17_custom_signal.png differ diff --git a/getting_started/step_by_step/img/signals_advanced_connection_window.png b/getting_started/step_by_step/img/signals_advanced_connection_window.png new file mode 100644 index 000000000..03a5f19f2 Binary files /dev/null and b/getting_started/step_by_step/img/signals_advanced_connection_window.png differ diff --git a/getting_started/step_by_step/img/tree.png b/getting_started/step_by_step/img/tree.png deleted file mode 100644 index 109bb2e5d..000000000 Binary files a/getting_started/step_by_step/img/tree.png and /dev/null differ diff --git a/getting_started/step_by_step/index.rst b/getting_started/step_by_step/index.rst index 918c975b6..cf422a1ba 100644 --- a/getting_started/step_by_step/index.rst +++ b/getting_started/step_by_step/index.rst @@ -1,14 +1,26 @@ Step by step ============ +This series builds upon the :ref:`Introduction to Godot +` and will get you started with the editor and the +engine. You will learn more about nodes and scenes, code your first classes with +GDScript, use signals to make nodes communicate with one another, and more. + +The following lessons are here to prepare you for :ref:`doc_your_first_game`, a +step-by-step tutorial where you will code a game from scratch. By the end of it, +you will have the necessary foundations to explore more features in other +sections. We also included links to pages that cover a given topic in-depth +where appropriate. + .. toctree:: :maxdepth: 1 :name: toc-learn-step_by_step - scenes_and_nodes + nodes_and_scenes instancing - instancing_continued - scripting + scripting_languages + scripting_first_script + scripting_player_input signals your_first_game exporting diff --git a/getting_started/step_by_step/instancing.rst b/getting_started/step_by_step/instancing.rst index 60bd6bca8..1bc472b42 100644 --- a/getting_started/step_by_step/instancing.rst +++ b/getting_started/step_by_step/instancing.rst @@ -1,123 +1,219 @@ .. _doc_instancing: -Instancing -========== +Creating instances +================== -Introduction ------------- +In the previous part, we saw that a scene is a collection of nodes organized in +a tree structure, with a single node as its root. You can split your project +into any number of scenes. This feature helps you break down and organize your +game's different components. -Creating a single scene and adding nodes into it might work for small -projects, but as a project grows in size and complexity, the number of nodes -can quickly become unmanageable. To address this, Godot allows a project -to be separated into any number of scenes. This provides you with a powerful -tool that helps you organize the different components of your game. +You can create as many scenes as you'd like and save them to the disk with the +``.tscn`` extension, which stands for "text scene". The ``Label.tscn`` file from +the previous lesson was an example. We call those files "Packed Scenes" as they +pack information about your scene's content. -In :ref:`doc_scenes_and_nodes` you learned that a scene is a collection of -nodes organized in a tree structure, with a single node as the tree root. +Here's the example of a ball. It's composed of a :ref:`RigidBody2D +` node as its root named Ball, which allows the ball to fall +and bounce on walls, a :ref:`Sprite ` node, and a +:ref:`CollisionShape2D `. -.. image:: img/tree.png +.. image:: img/instancing_ball_scene.png -You can create as many scenes as you like and save them to disk. Scenes -saved in this manner are called "Packed Scenes" and have a ``.tscn`` filename -extension. +Once you saved a scene, it works as a blueprint: you can reproduce it in other +scenes as many times as you'd like. Replicating an object from a template like +so is called **instancing**. -.. image:: img/instancingpre.png +.. image:: img/instancing_ball_instances_example.png -Once a scene has been saved, it can be instanced into another scene as -if it were any other node. +As we mentioned in the previous part, instanced scenes behave like a node: the +editor hides their content by default. When you instance the Ball, you only see +the Ball node. Notice also how each duplicate has a unique name. -.. image:: img/instancing.png +Every instance of the Ball scene starts with the same structure and properties +as ``Ball.tscn``. However, you can modify each independently, such as changing +how they bounce, how heavy they are, or any property exposed by the source +scene. -In the above picture, Scene B was added to Scene A as an instance. +In practice +----------- -Instancing by example ---------------------- +Let's use instancing in practice to see how it works exactly in Godot. We invite +you to download the ball's sample project we prepared for you: +:download:`instancing.zip `. -To learn how instancing works, let's start by downloading a sample -project: :download:`instancing.zip `. +Extract the archive on your computer. Then, open Godot, and in the project +manager, click the Import button to import the project. -Unzip this project anywhere you like. Then open Godot and add this project to -the project manager using the 'Import' button: +.. image:: img/instancing_import_button.png -.. image:: img/instancing_import.png +In the pop-up that appears, click the browse button and navigate to the folder +you extracted. -Browse to the folder you extracted and open the "project.godot" file you -can find inside it. After doing this, the new project will appear on the list -of projects. Edit the project by pressing the 'Edit' button. +.. image:: img/instancing_import_browse.png -This project contains two scenes: "Ball.tscn" and "Main.tscn". The ball -scene uses a :ref:`RigidBody2D ` to provide physics -behavior while the main scene has a set of obstacles for the ball to -collide with (using :ref:`StaticBody2D `). +Double-click the ``project.godot`` file to open it. -.. image:: img/instancing_ballscene.png +.. image:: img/instancing_import_project_file.png -.. image:: img/instancing_mainscene.png +Finally, click the Import & Edit button. -Open the ``Main`` scene, and then select the root node: +.. image:: img/instancing_import_and_edit_button.png -.. image:: img/instancing_mainroot.png +The project contains two packed scenes: ``Main.tscn``, containing walls against +which the ball collides, and ``Ball.tscn``. The Main scene should open +automatically. -We want to add an instance of the ``Ball`` scene as a child of ``Main``. -Click the "link"-shaped button (its hover-text says "Instance a scene file -as a Node.") and select the ``Ball.tscn`` file. +.. image:: img/instancing_main_scene.png -.. image:: img/instancing_linkbutton.png +Let's add a ball as a child of the Main node. In the Scene dock, select the Main +node. Then, click the link icon at the top of the scene dock. This button allows +you to add an instance of a scene as a child of the currently selected node. -The ball will be placed at the top-left corner of the screen area (this is -``(0, 0)`` in screen coordinates). Click and drag the ball somewhere near -the top-center of the scene: +.. image:: img/instancing_scene_link_button.png -.. image:: img/instancing_placeball.png +Double-click the ball scene to instance it. -Press "Play" and watch the ball fall to the bottom of the screen: +.. image:: img/instancing_instance_child_window.png -.. image:: img/instancing_playbutton.png +The ball appears in the top-left corner of the viewport. -Multiple instances ------------------- +.. image:: img/instancing_ball_instanced.png -You can add as many instances as you like to a scene, either by using the -"Instance" button again, or by clicking on the ball instance and pressing -:kbd:`Ctrl + D` (:kbd:`Cmd + D` on macOS) to duplicate it: +Click on it and drag it towards the center of the view. -.. image:: img/instancing_multiball.png +.. image:: img/instancing_ball_moved.png -Run the scene again and all of the balls will fall. +Play the game by pressing F5. You should see it fall. -.. image:: img/instancing_multiball.gif +Now, we want to create more instances of the Ball node. With the ball still +selected, press :kbd:`Ctrl-D` (:kbd:`Cmd-D` on macOS) to call the duplicate +command. Click and drag to move the new ball to a different location. -Editing instances ------------------ +.. image:: img/instancing_ball_duplicated.png -Open the ``Ball`` scene, expand the ``PhysicsMaterial`` by clicking on it, -and set the ``Bounce`` property to ``1``. +You can repeat this process until you have several in the scene. -.. image:: img/instancing_physicsmat2.png +.. image:: img/instancing_main_scene_with_balls.png -Press "Play" and notice that all of the instanced balls are now -much more bouncy. Because the instanced balls are based on the saved scene, -changes to that scene will affect all instances. +Play the game again. You should now see every ball fall independently from one +another. This is what instances do. Each is an independent reproduction of a +template scene. -You can also adjust individual instances. Set the bounce value back to ``0`` -and then in the ``Main`` scene, select one of the instanced balls. Resources -like ``PhysicsMaterial`` are shared between instances by default, so we need -to make it unique. Click on the tools button in the top-right of the Inspector -dock and select "Make Sub-Resources Unique". Set its ``Bounce`` to ``1`` and -press "Play". +Editing scenes and instances +---------------------------- -.. image:: img/instancing_property.png +There is more to instances. With this feature, you can: -Notice that a grey "revert" button appears next to the adjusted property. When -this button is present, it means you modified a property in the -instanced scene to override its value in the saved scene. Even -if that property is modified in the original scene, the custom value -will remain. Pressing the revert button will restore the property to the -value in the saved scene. +1. Change the properties of one ball without affecting the others using the + Inspector. +2. Change the default properties of every Ball by opening ``Ball.tscn`` scene + and making a change to the Ball node there. Upon saving, all instances of the + Ball in the project will see their values update. -Conclusion ----------- +.. note:: Changing a property on an instance always overrides values from the + corresponding packed scene. -Instancing can be useful when you want to create many copies of the -same object. It is also possible to create instances in code by using -GDScript, see :ref:`doc_instancing_continued`. +Let's try this. Open ``Ball.tscn`` and select the Ball node. In the Inspector on +the right, click on the PhysicsMaterial property to expand it. + +.. image:: img/instancing_physics_material_expand.png + +Set its Bounce property to ``2`` by clicking on the number field, typing ``2``, +and pressing :kbd:`Enter`. + +.. image:: img/instancing_property_bounce_updated.png + +Play the game by pressing :kbd:`F5` and notice how all balls now bounce a lot +more. As the Ball scene is a template for all instances, modifying it and saving +causes all instances to update accordingly. + +Let's now adjust an individual instance. Head back to the Main scene by clicking +on the corresponding tab above the viewport. + +.. image:: img/instancing_scene_tabs.png + +Select one of the instanced Ball nodes and, in the Inspector, set its Gravity +Scale value to ``10``. + +.. image:: img/instancing_property_gravity_scale.png + +A grey "revert" button appears next to the adjusted property. + +.. image:: img/instancing_property_revert_icon.png + +This icon indicates you are overriding a value from the source packed scene. +Even if you modify the property in the original scene, the value override will +be preserved in the instance. Clicking the revert icon will restore the +property to the value in the saved scene. + +Rerun the game and notice how this ball now falls much faster than the others. + +.. note:: If you change a value on the ``PhysicsMaterial`` of one instance, it + will affect all the others. This is because ``PhysicsMaterial`` is a + resource, and resources are shared between instances. To make a + resource unique for one instance, right-click on it in the Inspector + and click Make Unique in the contextual menu. + + Resources are another essential building block of Godot games we will + cover in a later lesson. + +Scene instances as a design language +------------------------------------ + +Instances and scenes in Godot offer an excellent design language, setting the +engine apart from others out there. We designed Godot around this concept from +the ground up. + +We recommend dismissing architectural code patterns when making games with +Godot, such as Model-View-Controller (MVC) or Entity-Relationship diagrams. +Instead, you can start by imagining the elements players will see in your game +and structure your code around them. + +For example, you could break down a simple shooter game like so: + +.. image:: img/instancing_diagram_shooter.png + +You can come up with a diagram like this for almost any type of game. Each +rectangle represents an entity that's visible in the game from the player's +perspective. The arrows tell you which scene owns which. + +Once you have a diagram, we recommended creating a scene for each element listed +in it to develop your game. You'll use instancing, either by code or directly in +the editor, to build your tree of scenes. + +Programmers tend to spend a lot of time designing abstract architectures and +trying to fit components into it. Designing based on scenes makes development +faster and more straightforward, allowing you to focus on the game logic itself. +Because most game components map directly to a scene, using a design based on +scene instantiation means you need little other architectural code. + +Here's the example of a scene diagram for an open-world game with tons of assets +and nested elements: + +.. image:: img/instancing_diagram_open_world.png + +Imagine we started by creating the room. We could make a couple of different +room scenes, with unique arrangements of furniture in them. Later, we could make +a house scene that uses multiple room instances for the interior. We would +create a citadel out of many instanced houses and a large terrain on which we +would place the citadel. Each of these would be a scene instancing one or more sub-scenes. + +Later, we could create scenes representing guards and add them to the citadel. +They would be indirectly added to the overall game world. + +With Godot, it's easy to iterate on your game like this, as all you need to do +is create and instantiate more scenes. We designed the editor to be accessible +to programmers, designers, and artists alike. A typical team development process +can involve 2D or 3D artists, level designers, game designers, and animators, +all working with the Godot editor. + +Summary +------- + +Instancing, the process of producing an object from a blueprint has many handy +uses. With scenes, it gives you: + +- The ability to divide your game into reusable components. +- A tool to structure and encapsulate complex systems. +- A language to think about your game project's structure in a natural way. diff --git a/getting_started/step_by_step/instancing_continued.rst b/getting_started/step_by_step/instancing_continued.rst deleted file mode 100644 index f3f9b57df..000000000 --- a/getting_started/step_by_step/instancing_continued.rst +++ /dev/null @@ -1,81 +0,0 @@ -.. _doc_instancing_continued: - -Instancing (continued) -====================== - -Recap ------ - -Instancing has many handy uses. At a glance, with instancing you have: - -- The ability to subdivide scenes and make them easier to manage. -- A tool to manage and edit multiple node instances at once. -- A way to organize and embed complex game flows or even UIs (in Godot, UI - Elements are nodes, too). - -Design language ---------------- - -But the greatest strength that comes with instancing scenes is that it works -as an excellent design language. This distinguishes Godot -from all the other engines out there. Godot was designed from the ground up -around this concept. - -When making games with Godot, the recommended approach is to dismiss most -common design patterns, such as MVC or Entity-Relationship diagrams, and -instead think about your scenes in a more natural way. Start by imagining the -visible elements in your game, the ones that can be named not just by a -programmer, but by anyone. - -For example, here's how a simple shooter game could be imagined: - -.. image:: img/shooter_instancing.png - -You can come up with a diagram like this for almost any kind -of game. Write down the parts of the game that you can visualize, and then -add arrows to represent ownership of one component by another. - -Once you have a diagram like this, the recommended process for making a game is -to create a scene for each element listed in the diagram. You'll use instancing -(either by code or directly in the editor) for the ownership relationships. - -A lot of time spent in programming games (or software in general) is on -designing an architecture and fitting game components to that architecture. -Designing based on scenes replaces that approach and makes development much -faster and more straightforward, allowing you to concentrate on the game logic -itself. Because most game components map directly to a scene, using a design based on scene instantiation means little other architectural code is needed. - -Let's take a look at one more, somewhat more complex, example of an open-world -type game with lots of assets and nested elements: - -.. image:: img/openworld_instancing.png - -Take a look at the room element. Let's say we started there. We could make a -couple of different room scenes, with different arrangements of furniture (also -scenes) in them. Later, we could make a house scene, connecting rooms to make -up its interior. - -Then, we could make a citadel scene, which is made out of many instanced -houses. Then, we could start working on the world map terrain, adding the -citadel onto it. - -Later, we could create scenes that represent guards (and other NPCs) and add -them to the citadel as well. As a result, they would be indirectly added to the -overall game world. - -With Godot, it's easy to iterate on your game like this, as all you need to do -is create and instance more scenes. Furthermore, the editor UI is designed to be user -friendly for programmers and non-programmers alike. A typical team development -process can involve 2D or 3D artists, level designers, game designers, -and animators, all working with the editor interface. - -Information overload! ---------------------- - -This has been a lot of high level information dropped on you all at once. -However, the important part of this tutorial was to create an awareness of how -scenes and instancing are used in real projects. - -Everything discussed here will become second nature to you once you start -making games and putting these concepts into practice. For now, don't worry -about it too much, and go on to the next tutorial! diff --git a/getting_started/step_by_step/nodes_and_scenes.rst b/getting_started/step_by_step/nodes_and_scenes.rst new file mode 100644 index 000000000..ffa49f68d --- /dev/null +++ b/getting_started/step_by_step/nodes_and_scenes.rst @@ -0,0 +1,196 @@ +.. The goal of this page is to explain more than doc_key_concepts_overview about nodes and scenes, get the user to create their first concrete scene. + +.. _doc_nodes_and_scenes: + +Nodes and Scenes +================ + +In :ref:`doc_key_concepts_overview`, we saw that a Godot game is a tree of +scenes and that each scene is a tree of nodes. In this lesson, we explain a bit +more about them. You will also create your first scene. + +Nodes +----- + +**Nodes are the fundamental building blocks of your game**. They are like the +ingredients in a recipe. There are dozens of kinds that can display an image, +play a sound, represent a camera, and much more. + +.. image:: img/nodes_and_scenes_nodes.png + +All nodes have the following attributes: + +- A name. +- Editable properties. +- They receive callbacks to update every frame. +- You can extend them with new properties and functions. +- You can add them to another node as a child. + +The last attribute is key. **Together, nodes form a tree**, which is a powerful +feature to organize projects. Since different nodes have different functions, +combining them produces more complex behavior. As we saw before, you can build a +playable character the camera follows using a kinematic body node named +"Character", a sprite node, a camera node, and a collision shape node. + +.. image:: img/nodes_and_scenes_character_nodes.png + +Scenes +------ + +When you organize nodes in a tree, like our character, we call this construct a +scene. Once saved, scenes work like new node types in the editor, where you can +add them as a child of an existing node. In that case, the instance of the scene +appears as a single node with its internals hidden. + +Scenes allow you to structure your game's code however you want. You can +**compose nodes** to create custom and complex node types, like a game character +that runs and jumps, a life bar, a chest with which you can interact, and more. + +.. image:: img/nodes_and_scenes_3d_scene_example.png + +The Godot editor essentially is a **scene editor**. It has plenty of tools for +editing 2D and 3D scenes, as well as user interfaces. A Godot project can +contain as many of these scenes as you need. The engine only requires one as +your application's **main scene**. This is the scene Godot will first load when +you or a player runs the game. + +On top of acting like nodes, scenes have the following attributes: + +1. They always have one root node, like the "Character" in our example. +2. You can save them to your hard drive and load them later. +3. You can create as many instances of a scene as you'd like. You could have + five or ten characters in your game, created from your Character scene. + +Creating your first scene +------------------------- + +Let's create our first scene with a single node. To do so, you will need to +:ref:`create a new project ` first. After +opening the project, you should see an empty editor. + +.. image:: img/nodes_and_scenes_01_empty_editor.png + +In an empty scene, the Scene dock on the left shows several options to add a +root node quickly. "2D Scene" adds a Node2D node, "3D Scene" adds a Spatial +node, "User Interface" adds a Control node, and "Other Node" lets you select any +node. It is equivalent to pressing the "Add Child Node" button. These presets +are here for convenience; they are not mandatory. + +We're going to add a single Label node to our scene. Its function is to draw +text on the screen. + +Press the "Add Child Node" button at the top left of the Scene dock to create a +node. This button adds the chosen node as a child of the currently selected one +or, in an empty scene, as the root. + +.. image:: img/nodes_and_scenes_02_scene_dock.png + +The Create Node dialog opens, showing the long list of available nodes. + +.. image:: img/nodes_and_scenes_03_create_node_window.png + +Select the Label node. You can type its name to filter down the list. + +.. image:: img/nodes_and_scenes_04_create_label_window.png + +Click on the Label node to select it and click the Create button at the bottom +of the window. + +.. image:: img/nodes_and_scenes_05_editor_with_label.png + +A lot happens when you add a scene's first node. The scene changes to the 2D +workspace because Label is a 2D node type. The Label appears, selected, in the +top-left corner of the viewport. The node appears in the Scene dock on the left, +and the node's properties appear in the Inspector dock on the right. + +Changing a node's properties +---------------------------- + +The next step is to change the Label's "Text" property. Let's change it to +"Hello World". + +Head to the Inspector dock on the right of the viewport. Click inside the field +below the Text property and type "Hello World". + +.. image:: img/nodes_and_scenes_06_label_text.png + +You will see the text draw in the viewport as you type. + +.. seealso:: You can edit any property listed in the Inspector as we did with + the Text. For a complete reference of the Inspector dock, see the + :ref:`doc_editor_inspector_dock`. + +You can move your Label node in the viewport by selecting the move tool in the +toolbar. + +.. image:: img/nodes_and_scenes_07_move_tool.png + +With the Label selected, click and drag anywhere in the viewport to +move it to the center of the view delimited by the rectangle. + +.. image:: img/nodes_and_scenes_08_hello_world_text.png + +Running the scene +----------------- + +Everything's ready to run the scene! Press the Play Scene button in the +top-right of the screen or press :kbd:`F6`. + +.. image:: img/nodes_and_scenes_09_play_scene_button.png + +A popup invites you to save the scene, which is required to run it. + +.. image:: img/nodes_and_scenes_10_save_scene_popup.png + +Click the Yes button, and in the file browser that appears, press the Save +button to save it as "Label.tscn". + +.. image:: img/nodes_and_scenes_11_save_scene_as.png + +.. note:: The Save Scene As dialog, like other file dialogs in the editor, only + allows you to save files inside the project. The ``res://`` path at + the top of the window represents the project's root directory and + stands for "resource path". For more information about file paths in + Godot, see :ref:`doc_filesystem`. + +The application should open in a new window and display the text "Hello World". + +.. image:: img/nodes_and_scenes_12_final_result.png + +Close the window or press :kbd:`F8` to quit the running scene. + +.. note:: + + If this doesn't immediately work and you have a hiDPI display on at least + one of your monitors, go to Project -> Project Settings -> Display -> + Window then enable Allow Hidpi under Dpi. + +Setting the main scene +---------------------- + +To run our test scene, we used the Play Scene button. Another button next to it +allows you to set and run the project's main scene. You can press :kbd:`F5` to +do so. + +.. image:: img/nodes_and_scenes_13_play_button.png + +A popup window appears and invites you to select the main scene. + +.. image:: img/nodes_and_scenes_14_main_scene_popup.png + +Click the Select button, and in the file dialog that appears, double click on +Label.tscn. + +.. image:: img/nodes_and_scenes_15_select_main_scene.png + +The demo should run again. Moving forward, every time you run the project, Godot +will use this scene as a starting point. + +.. note:: The editor saves the main scene's path in a project.godot file in your + project's directory. While you can edit this text file directly to + change project settings, you can also use the "Project -> Project + Settings" window to do so. For more information, see + :ref:`doc_project_settings`. + +In the next part, we will discuss another key concept in games and in Godot: +creating instances of a scene. diff --git a/getting_started/step_by_step/scenes_and_nodes.rst b/getting_started/step_by_step/scenes_and_nodes.rst deleted file mode 100644 index 538994baa..000000000 --- a/getting_started/step_by_step/scenes_and_nodes.rst +++ /dev/null @@ -1,216 +0,0 @@ -.. _doc_scenes_and_nodes: - -Scenes and nodes -================ - -Introduction ------------- - -.. image:: img/chef.png - -Imagine for a second that you are not a game developer anymore. Instead, -you're a chef! Change your hipster outfit for a toque and a double -breasted jacket. Now, instead of making games, you create new and -delicious recipes for your guests. - -So, how does a chef create a recipe? Recipes are divided into two -sections: the first is the ingredients and the second is the -instructions to prepare it. This way, anyone can follow the recipe and -savor your magnificent creation. - -Making games in Godot feels pretty much the same way. Using the engine -feels like being in a kitchen. In this kitchen, *nodes* are like a -refrigerator full of fresh ingredients with which to cook. - -There are many types of nodes. Some show images, others play sound, -other nodes display 3D models, etc. There are dozens of them. - -Nodes ------ - -But let's start with the basics. Nodes are fundamental building blocks for -creating a game. As mentioned above, a node can perform a variety of specialized -functions. However, any given node always has the following attributes: - -- It has a name. -- It has editable properties. -- It can receive a callback to process every frame. -- It can be extended (to have more functions). -- It can be added to another node as a child. - -.. image:: img/tree.png - -The last one is important. Nodes can have other nodes as -children. When arranged in this way, the nodes become a **tree**. - -In Godot, the ability to arrange nodes in this way creates a powerful -tool for organizing projects. Since different nodes have different -functions, combining them allows for the creation of more complex functions. - -Don't worry if this doesn't click yet. We will continue to explore this over -the next few sections. The most important fact to remember for now is that -nodes exist and can be arranged this way. - -Scenes ------- - -.. image:: img/scene_tree_example.png - -Now that the concept of nodes has been defined, the next logical -step is to explain what a Scene is. - -A scene is composed of a group of nodes organized hierarchically (in -tree fashion). Furthermore, a scene: - -- always has one root node. -- can be saved to disk and loaded back. -- can be *instanced* (more on that later). - -Running a game means running a scene. A project can contain several scenes, -but for the game to start, one of them must be selected as the main scene. - -Basically, the Godot editor is a **scene editor**. It has plenty of tools for -editing 2D and 3D scenes as well as user interfaces, but the editor is based on -the concept of editing a scene and the nodes that compose it. - -Editor ------- - -Open the project you made in :ref:`doc_intro_to_the_editor_interface`, or create a new one. This will -open the Godot editor: - -.. image:: img/empty_editor.png - -As mentioned before, making games in Godot feels like being in a -kitchen, so let's open the refrigerator and add some fresh nodes to the -project. We'll begin with a "Hello World" message that we'll put on the -screen. - -To do this we need to add a Label node. Press the "Add Child Node" button -at the top left of the scene dock (the icon represents a plus symbol). -This button is the main way to add new nodes to a scene, and will always -add the chosen node as a child of the currently selected node (or, in an -empty scene, as the "root" node). - -.. note:: - - In an empty scene (without root node), the scene dock shows several - options to quickly add a root node to the scene. "2D Scene" adds a - Node2D node, "3D Scene" adds a Spatial node, "User Interface" adds a - Control node, and "Other Node" which lets you select any node (so it - is equivalent to pressing the "Add Child Node" button). You can also - press the star-shaped icon to toggle the display of your favorited - nodes. - - Note that these presets are here for convenience and are not mandatory - for the different types of scenes. Not every 3D scene needs a Spatial - node as its root node, likewise not every GUI or 2D scene needs a Control - node or Node2D as their root node. - -Now, to add a label node to this scene you can click on the Other Node -button or the Add Node button at the top. In scenes that aren't empty you -use the add node button to create every child node. - -.. image:: img/newnode_button.png - -This will open the Create Node dialog, showing the long list of nodes -that can be created: - -.. image:: img/node_classes.png - -From there, select the "Label" node first. Searching for it is probably -the fastest way: - -.. image:: img/node_search_label.png - -And finally, create the Label! A lot happens when Create is pressed: - -.. image:: img/editor_with_label.png - -First of all, the scene changes to the 2D editor (because Label is a 2D Node -type), and the Label appears, selected, at the top left corner of the viewport. - -The node appears in the scene tree editor in the Scene dock, and the label -properties appear in the Inspector dock. - -The next step will be to change the "Text" Property of the label. Let's -change it to "Hello World": - -.. image:: img/hw.png - -Ok, everything's ready to run the scene! Press the PLAY SCENE Button on -the top bar (or hit :kbd:`F6`): - -.. image:: img/playscene.png - -Aaaand... Oops. - -.. image:: img/neversaved.png - -Scenes need to be saved to be run, so save the scene to something like -Hello.tscn in Scene -> Save: - -.. image:: img/save_scene.png - -And here's when something funny happens. The file dialog is a special -file dialog, and only allows you to save inside the project. The project -root is ``res://`` which means "resource path". This means that files can -only be saved inside the project. For the future, when doing file -operations in Godot, remember that ``res://`` is the resource path, and no -matter the platform or install location, it is the way to locate where -resource files are from inside the game. - -After saving the scene and pressing run scene again, the "Hello World" -demo should finally execute: - -.. image:: img/helloworld.png - -Success! - -.. note:: - - If this doesn't immediately work and you have a hiDPI display on - at least one of your monitors, go to - **Project → Project Settings → Display → Window** then enable - **Allow Hidpi** under **Dpi**. - -.. _doc_scenes_and_nodes-configuring_the_project: - -Configuring the project ------------------------ - -Ok, it's time to configure the project. Right now, the only way to run -something is to execute the current scene. Projects, however, may have several -scenes, so one of them must be set as the main scene. This is the scene that -will be loaded any time the project is run. - -These settings are all stored in a project.godot file, which is a plaintext -file in win.ini format (for easy editing). There are dozens of settings that -you can change in this file to alter how a project executes. To simplify this -process, Godot provides a project settings dialog, which acts as a sort of -frontend to editing a project.godot file. - -To access that dialog, select Project -> Project Settings. Try it now. - -Once the window opens, let's select a main scene. Locate the -`Application/Run/Main Scene` property and click on it to select 'Hello.tscn'. - -.. image:: img/main_scene.png - -Now, with this change, when you press the regular Play button (or F5), this -scene will run, no matter which scene is actively being edited. - -The project settings dialog provides a lot of options that can be saved to a -project.godot file and shows their default values. If you change a value, a -tick is marked to the left of its name. This means that the property will be -saved to the project.godot file and remembered. - -As a side note, it is also possible to add custom configuration options and -read them in at run-time using the :ref:`ProjectSettings ` singleton. - -To be continued... ------------------- - -This tutorial talked about "scenes and nodes", but so far there has been -only *one* scene and *one* node! Don't worry, the next tutorial will -expand on that... diff --git a/getting_started/step_by_step/scripting.rst b/getting_started/step_by_step/scripting.rst deleted file mode 100644 index d0939a798..000000000 --- a/getting_started/step_by_step/scripting.rst +++ /dev/null @@ -1,342 +0,0 @@ -.. _doc_scripting: - -Scripting -========= - -Introduction ------------- - -Before Godot 3.0, the only choice for scripting a game was to use -:ref:`GDScript`. Nowadays, Godot has four (yes, four!) official languages -and the ability to add extra scripting languages dynamically! - -This is great, mostly due to the large amount of flexibility provided, but -it also makes our work supporting languages more difficult. - -The "main" languages in Godot, though, are GDScript and VisualScript. The -main reason to choose them is their level of integration with Godot, as this -makes the experience smoother; both have slick editor integration, while -C# and C++ need to be edited in a separate IDE. If you are a big fan of statically typed languages, go with C# and C++ instead. - -GDScript -~~~~~~~~ - -:ref:`GDScript` is, as mentioned above, the main language used in Godot. -Using it has some positive points compared to other languages due -to its high integration with Godot: - -* It's simple, elegant, and designed to be familiar for users of other languages such as Lua, Python, Squirrel, etc. -* Loads and compiles blazingly fast. -* The editor integration is a pleasure to work with, with code completion for nodes, signals, and many other items pertaining to the scene being edited. -* Has vector types built-in (such as Vectors, transforms, etc.), making it efficient for heavy use of linear algebra. -* Supports multiple threads as efficiently as statically typed languages - one of the limitations that made us avoid VMs such as Lua, Squirrel, etc. -* Uses no garbage collector, so it trades a small bit of automation (most objects are reference counted anyway), by determinism. -* Its dynamic nature makes it easy to optimize sections of code in C++ (via GDNative) if more performance is required, all without recompiling the engine. - -If you're undecided and have experience with programming, especially dynamically -typed languages, go for GDScript! - -VisualScript -~~~~~~~~~~~~ - -Beginning with 3.0, Godot offers :ref:`Visual Scripting`. This is a -typical implementation of a "blocks and connections" language, but -adapted to how Godot works. - -Visual scripting is a great tool for non-programmers, or even for experienced developers -who want to make parts of the code more accessible to others, -like game designers or artists. - -It can also be used by programmers to build state machines or custom -visual node workflows - for example, a dialogue system. - - -.NET / C# -~~~~~~~~~ - -As Microsoft's C# is a favorite amongst game developers, we have added -official support for it. C# is a mature language with tons of code -written for it, and support was added thanks to -a generous donation from Microsoft. - -It has an excellent tradeoff between performance and ease of use, -although one must be aware of its garbage collector. - -Since Godot uses the `Mono `_ .NET runtime, in theory -any third-party .NET library or framework can be used for scripting in Godot, as -well as any Common Language Infrastructure-compliant programming language, such as -F#, Boo or ClojureCLR. In practice however, C# is the only officially supported .NET option. - -GDNative / C++ -~~~~~~~~~~~~~~ - -Finally, one of our brightest additions for the 3.0 release: -GDNative allows scripting in C++ without needing to recompile (or even -restart) Godot. - -Any C++ version can be used, and mixing compiler brands and versions for the -generated shared libraries works perfectly, thanks to our use of an internal C -API Bridge. - -This language is the best choice for performance and does not need to be -used throughout an entire game, as other parts can be written in GDScript or Visual -Script. However, the API is clear and easy to use as it resembles, mostly, -Godot's actual C++ API. - -More languages can be made available through the GDNative interface, but keep in mind -we don't have official support for them. - -Scripting a scene ------------------ - -For the rest of this tutorial we'll set up a GUI scene consisting of a -button and a label, where pressing the button will update the label. This will -demonstrate: - -- Writing a script and attaching it to a node. -- Hooking up UI elements via signals. -- Writing a script that can access other nodes in the scene. - -Before continuing, make sure to skim and bookmark the :ref:`GDScript` reference. -It's a language designed to be simple, and the reference is structured into sections to make it -easier to get an overview of the concepts. - -Scene setup -~~~~~~~~~~~ - -If you still have the "instancing" project open from the previous tutorial, then close that out (Project -> Quit to Project List) and create a New Project. - -Use the "Add Child Node" dialogue accessed from the Scene tab (or by pressing :kbd:`Ctrl + A`) to create a hierarchy with the following -nodes: - -- Panel - - * Label - * Button - -The scene tree should look like this: - -.. image:: img/scripting_scene_tree.png - -Use the 2D editor to position and resize the Button and Label so that they -look like the image below. You can set the text from the Inspector tab. - -.. image:: img/label_button_example.png - -Finally, save the scene with a name such as ``sayhello.tscn``. - -.. _doc_scripting-adding_a_script: - -Adding a script -~~~~~~~~~~~~~~~ - -Right click on the Panel node, then select "Attach Script" from the context -menu: - -.. image:: img/add_script.png - -The script creation dialog will pop up. This dialog allows you to set the -script's language, class name, and other relevant options. - -In GDScript, the file itself represents the class, so -the class name field is not editable. - -The node we're attaching the script to is a panel, so the Inherits field -will automatically be filled in with "Panel". This is what we want, as the -script's goal is to extend the functionality of our panel node. - -Finally, enter a path name for the script and select Create: - -.. image:: img/script_create.png - -The script will then be created and added to the node. You can -see this as an "Open script" icon next to the node in the Scene tab, -as well as in the script property under Inspector: - -.. image:: img/script_added.png - -To edit the script, select either of these buttons, both of which are highlighted in the above image. -This will bring you to the script editor, where a default template will be included: - -.. image:: img/script_template.png - -There's not much there. The ``_ready()`` function is called when the -node, and all its children, enters the active scene. **Note:** ``_ready()`` is not -the constructor; the constructor is instead ``_init()``. - -The role of the script -~~~~~~~~~~~~~~~~~~~~~~ - -A script adds behavior to a node. It is used to control how the node functions -as well as how it interacts with other nodes: children, parent, siblings, -and so on. The local scope of the script is the node. In other words, the script -inherits the functions provided by that node. - -.. image:: img/brainslug.jpg - - -.. _doc_scripting_handling_a_signal: - -Handling a signal -~~~~~~~~~~~~~~~~~ - -Signals are "emitted" when some specific kind of action happens, and they can be -connected to any function of any script instance. Signals are used mostly in -GUI nodes, although other nodes have them too, and you can even define custom -signals in your own scripts. - -In this step, we'll connect the "pressed" signal to a custom function. Forming -connections is the first part and defining the custom function is the second part. -For the first part, Godot provides two ways to create connections: through a -visual interface the editor provides or through code. - -While we will use the code method for the remainder of this tutorial series, let's -cover how the editor interface works for future reference. - -Select the Button node in the scene tree and then select the "Node" tab. Next, -make sure that you have "Signals" selected. - -.. image:: img/signals.png - -If you then select "pressed()" under "BaseButton" and click the "Connect..." -button in the bottom right, you'll open up the connection creation dialogue. - -.. image:: img/connect_dialogue.png - -The top of the dialogue displays a list of your scene's nodes with the emitting -node's name highlighted in blue. Select the "Panel" node here. - -The bottom of the dialogue shows the name of the method that will be created. -By default, the method name will contain the emitting node's name ("Button" in -this case), resulting in ``_on_[EmitterNode]_[signal_name]``. - -And that concludes the guide on how to use the visual interface. However, this -is a scripting tutorial, so for the sake of learning, let's dive into the -manual process! - -To accomplish this, we will introduce a function that is probably the most used -by Godot programmers: :ref:`Node.get_node() `. -This function uses paths to fetch nodes anywhere in the scene, relative to the -node that owns the script. - -For the sake of convenience, delete everything underneath ``extends Panel``. -You will fill out the rest of the script manually. - -Because the Button and Label are siblings under the Panel -where the script is attached, you can fetch the Button by typing -the following underneath the ``_ready()`` function: - -.. tabs:: - .. code-tab:: gdscript GDScript - - func _ready(): - get_node("Button") - - .. code-tab:: csharp - - public override void _Ready() - { - GetNode("Button"); - } - -Next, write a function which will be called when the button is pressed: - -.. tabs:: - .. code-tab:: gdscript GDScript - - func _on_Button_pressed(): - get_node("Label").text = "HELLO!" - - .. code-tab:: csharp - - public void _OnButtonPressed() - { - GetNode