Browse Source

Merge pull request #1498 from mhilbrunner/mhilbrunner-step-by-step-script

Step-by-step scripting: Reorder functions
Max Hilbrunner 7 years ago
parent
commit
a7f9ddeb54
1 changed files with 8 additions and 5 deletions
  1. 8 5
      getting_started/step_by_step/scripting.rst

+ 8 - 5
getting_started/step_by_step/scripting.rst

@@ -290,6 +290,9 @@ The final script should look like this:
     func _on_Button_pressed():
     func _on_Button_pressed():
         get_node("Label").text = "HELLO!"
         get_node("Label").text = "HELLO!"
 
 
+    func _on_button_pressed():
+        get_node("Label").text = "HELLO!"
+
  .. code-tab:: csharp
  .. code-tab:: csharp
 
 
     using Godot;
     using Godot;
@@ -298,15 +301,15 @@ The final script should look like this:
     // this is case sensitive!
     // this is case sensitive!
     public class sayhello : Panel
     public class sayhello : Panel
     {
     {
-        public void _OnButtonPressed()
+        public override void _Ready()
         {
         {
-            var label = (Label)GetNode("Label");
-            label.Text = "HELLO!";
+            GetNode("Button").Connect("pressed", this, nameof(_OnButtonPressed));
         }
         }
 
 
-        public override void _Ready()
+        public void _OnButtonPressed()
         {
         {
-            GetNode("Button").Connect("pressed", this, nameof(_OnButtonPressed));
+            var label = (Label)GetNode("Label");
+            label.Text = "HELLO!";
         }
         }
     }
     }