浏览代码

Update connecting signal code for Godot 4 (#5587)

Matthew 3 年之前
父节点
当前提交
a6566b9152
共有 1 个文件被更改,包括 4 次插入4 次删除
  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