mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-07 02:12:07 +03:00
Update connecting signal code for Godot 4 (#5587)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user