Browse Source

Update connecting signal code for Godot 4 (#5587)

Matthew 3 years ago
parent
commit
a6566b9152
1 changed files with 4 additions and 4 deletions
  1. 4 4
      getting_started/step_by_step/signals.rst

+ 4 - 4
getting_started/step_by_step/signals.rst

@@ -251,12 +251,12 @@ We can now connect the Timer to the Sprite2D in the ``_ready()`` function.
 
     func _ready():
         var timer = get_node("Timer")
-        timer.connect("timeout", self, "_on_Timer_timeout")
+        timer.timeout.connect(_on_Timer_timeout)
 
 The line reads like so: we connect the Timer's "timeout" signal to the node to
-which the script is attached (``self``). When the Timer emits "timeout", we want
-to call the function "_on_Timer_timeout", that we need to define. Let's add it
-at the bottom of our script and use it to toggle our sprite's visibility.
+which the script is attached. When the Timer emits ``timeout``, we want to call
+the function ``_on_Timer_timeout()``, that we need to define. Let's add it at the
+bottom of our script and use it to toggle our sprite's visibility.
 
 .. tabs::
  .. code-tab:: gdscript GDScript