diff --git a/img/add_script.png b/img/add_script.png new file mode 100644 index 000000000..b3362c2d6 Binary files /dev/null and b/img/add_script.png differ diff --git a/img/addscript.png b/img/addscript.png deleted file mode 100644 index f38fa3d4a..000000000 Binary files a/img/addscript.png and /dev/null differ diff --git a/img/button_connections.png b/img/button_connections.png deleted file mode 100644 index ffd9719d5..000000000 Binary files a/img/button_connections.png and /dev/null differ diff --git a/img/label_button_example.png b/img/label_button_example.png new file mode 100644 index 000000000..9d7db05d1 Binary files /dev/null and b/img/label_button_example.png differ diff --git a/img/script_added.png b/img/script_added.png new file mode 100644 index 000000000..69d21fba6 Binary files /dev/null and b/img/script_added.png differ diff --git a/img/script_create.png b/img/script_create.png new file mode 100644 index 000000000..f46dfdb5a Binary files /dev/null and b/img/script_create.png differ diff --git a/img/script_template.png b/img/script_template.png index d3c9d66e5..5d5b02a69 100644 Binary files a/img/script_template.png and b/img/script_template.png differ diff --git a/img/scriptadded.png b/img/scriptadded.png deleted file mode 100644 index 1656bf2d8..000000000 Binary files a/img/scriptadded.png and /dev/null differ diff --git a/img/scriptcreate.png b/img/scriptcreate.png deleted file mode 100644 index bbac9e269..000000000 Binary files a/img/scriptcreate.png and /dev/null differ diff --git a/img/scripthello.png b/img/scripthello.png deleted file mode 100644 index d0e587438..000000000 Binary files a/img/scripthello.png and /dev/null differ diff --git a/img/scripting_hello.png b/img/scripting_hello.png new file mode 100644 index 000000000..456ffa20d Binary files /dev/null and b/img/scripting_hello.png differ diff --git a/img/scripting_scene_tree.png b/img/scripting_scene_tree.png new file mode 100644 index 000000000..33e9c01a5 Binary files /dev/null and b/img/scripting_scene_tree.png differ diff --git a/img/scriptsceneimg.png b/img/scriptsceneimg.png deleted file mode 100644 index d2abdeace..000000000 Binary files a/img/scriptsceneimg.png and /dev/null differ diff --git a/img/signals.png b/img/signals.png index 455f2501e..5b2b04f77 100644 Binary files a/img/signals.png and b/img/signals.png differ diff --git a/tutorials/step_by_step/scripting.rst b/tutorials/step_by_step/scripting.rst index 91d9cca56..0fafb63fb 100644 --- a/tutorials/step_by_step/scripting.rst +++ b/tutorials/step_by_step/scripting.rst @@ -84,11 +84,11 @@ node dialog to create the following hierarchy, with the following nodes: It should look like this in the scene tree: -.. image:: /img/scriptscene.png +.. image:: /img/scripting_scene_tree.png And try to make it look like this in the 2D editor, so it makes sense: -.. image:: /img/scriptsceneimg.png +.. image:: /img/label_button_example.png Finally, save the scene, a fitting name could be "sayhello.scn" @@ -97,9 +97,10 @@ Finally, save the scene, a fitting name could be "sayhello.scn" Adding a script ~~~~~~~~~~~~~~~ -Select the Panel node, then press the "Add Script" Icon as follows: +Right click on the panel node, then select "Add Script" in the context +menu: -.. image:: /img/addscript.png +.. image:: /img/add_script.png The script creation dialog will pop up. This dialog allows to select the language, class name, etc. GDScript does not use class names in @@ -107,20 +108,19 @@ script files, so that field is not editable. The script should inherit from "Panel" (as it is meant to extend the node, which is of Panel type, this is automatically filled anyway). -Select the filename for the script (if you saved the scene previously, -one will be automatically generated as sayhello.gd) and push "Create": +Enter a path name for the script and then select "Create": -.. image:: /img/scriptcreate.png +.. image:: /img/script_create.png Once this is done, the script will be created and added to the node. You can see this both as an extra icon in the node, as well as in the script property: -.. image:: /img/scriptadded.png +.. image:: /img/script_added.png -To edit the script, pushing the icon above should do it (although, the -UI will take you directly to the Script editor screen). So, here's the -template script: +To edit the script, select either of the highlighted buttons. +This will bring you to the script editor where an existing template will +be included by default: .. image:: /img/script_template.png @@ -131,7 +131,7 @@ not a constructor, the constructor is "_init()" ). The role of the script ~~~~~~~~~~~~~~~~~~~~~~ -A script basically adds a behavior to a node. It is used to control the +A script adds behavior to a node. It is used to control the node functions as well as other nodes (children, parent, siblings, etc). The local scope of the script is the node (just like in regular inheritance) and the virtual functions of the node are captured by the @@ -148,21 +148,15 @@ and can be connected to any function of any script instance. In this step, the "pressed" signal from the button will be connected to a custom function. -There is a GUI for connecting signals, just select the node and press -the "Signals" button: +An interface for connecting signals to your scripts exists in the editor. +You can access this by selecting the node in the scene tree and then +selecting the "Node" tab. Make sure that you have "Signals" selected. .. image:: /img/signals.png -which will show the list of signals a Button can emit. - -.. image:: /img/button_connections.png - -But this example will not use it. We don't want to make things *too* -easy. So please close that screen! - In any case, at this point it is clear that that we are interested in -the "pressed" signal, so instead of doing it with the visual -interface, the connection will be done using code. +the "pressed" signal. Instead of doing it with the visual +interface, we will opt to make the connection using code. For this, there is a function that is probably the one that Godot programmers will use the most, this is @@ -212,7 +206,7 @@ The final script should look like this: Running the scene should have the expected result when pressing the button: -.. image:: /img/scripthello.png +.. image:: /img/scripting_hello.png **Note:** As it is a common mistake in this tutorial, let's clarify again that get_node(path) works by returning the *immediate* children of