Browse Source

Merge pull request #6236 from TheYellowArchitect/patch-6

[2D Game Tutorial] Polished HUD code explanation
Max Hilbrunner 2 years ago
parent
commit
51d2bedf2f
1 changed files with 10 additions and 10 deletions
  1. 10 10
      getting_started/first_2d_game/06.heads_up_display.rst

+ 10 - 10
getting_started/first_2d_game/06.heads_up_display.rst

@@ -72,14 +72,14 @@ ScoreLabel
 
 
 -  *Layout* : "Top Wide"
 -  *Layout* : "Top Wide"
 -  *Text* : ``0``
 -  *Text* : ``0``
--  *Align* : "Center"
+-  *Alignment* : "Center"
 
 
 Message
 Message
 ~~~~~~~~~~~~
 ~~~~~~~~~~~~
 
 
 -  *Layout* : "HCenter Wide"
 -  *Layout* : "HCenter Wide"
 -  *Text* : ``Dodge the Creeps!``
 -  *Text* : ``Dodge the Creeps!``
--  *Align* : "Center"
+-  *Alignment* : "Center"
 -  *Autowrap* : "On"
 -  *Autowrap* : "On"
 
 
 StartButton
 StartButton
@@ -102,6 +102,7 @@ Now add this script to ``HUD``:
 
 
     extends CanvasLayer
     extends CanvasLayer
 
 
+    # Notifies `Main` node that the button has been pressed
     signal start_game
     signal start_game
 
 
  .. code-tab:: csharp
  .. code-tab:: csharp
@@ -109,7 +110,7 @@ Now add this script to ``HUD``:
     public class HUD : CanvasLayer
     public class HUD : CanvasLayer
     {
     {
         // Don't forget to rebuild the project so the editor knows about the new signal.
         // Don't forget to rebuild the project so the editor knows about the new signal.
-
+        
         [Signal]
         [Signal]
         public delegate void StartGameEventHandler();
         public delegate void StartGameEventHandler();
     }
     }
@@ -155,8 +156,8 @@ Now add this script to ``HUD``:
 
 
     #endif // HUD_H
     #endif // HUD_H
 
 
-The ``start_game`` signal tells the ``Main`` node that the button
-has been pressed.
+We now want to display a message temporarily, 
+such as "Get Ready", so we add the following code
 
 
 .. tabs::
 .. tabs::
  .. code-tab:: gdscript GDScript
  .. code-tab:: gdscript GDScript
@@ -202,8 +203,7 @@ has been pressed.
         godot::register_signal<HUD>("start_game", godot::Dictionary());
         godot::register_signal<HUD>("start_game", godot::Dictionary());
     }
     }
 
 
-This function is called when we want to display a message
-temporarily, such as "Get Ready".
+We also need to process what happens when the player loses. The code below will show "Game Over" for 2 seconds, then return to the title screen and, after a brief pause, show the "Start" button.
 
 
 .. tabs::
 .. tabs::
  .. code-tab:: gdscript GDScript
  .. code-tab:: gdscript GDScript
@@ -262,6 +262,8 @@ seconds, then return to the title screen and, after a brief pause, show the
           can be very useful to add delays such as in the above code, where we
           can be very useful to add delays such as in the above code, where we
           want to wait some time before showing the "Start" button.
           want to wait some time before showing the "Start" button.
 
 
+Add the code below to ``Main`` to update the score
+
 .. tabs::
 .. tabs::
  .. code-tab:: gdscript GDScript
  .. code-tab:: gdscript GDScript
 
 
@@ -282,10 +284,8 @@ seconds, then return to the title screen and, after a brief pause, show the
         _score_label->set_text(godot::Variant(p_score));
         _score_label->set_text(godot::Variant(p_score));
     }
     }
 
 
-This function is called by ``Main`` whenever the score changes.
-
 Connect the ``timeout()`` signal of ``MessageTimer`` and the ``pressed()``
 Connect the ``timeout()`` signal of ``MessageTimer`` and the ``pressed()``
-signal of ``StartButton`` and add the following code to the new functions:
+signal of ``StartButton``, and add the following code to the new functions:
 
 
 .. tabs::
 .. tabs::
  .. code-tab:: gdscript GDScript
  .. code-tab:: gdscript GDScript