Built-in signals
- Game Development course
- Intermediate
- Lesson 68/83
- 4 min
Learn built-in signals like button.pressed.
Built-in signals
Most pre-built nodes in Godot come with built-in signals. For example, a Button node has a pressed signal, and a Timer node has a timeout signal.
# Button node emits pressed when clicked
# Timer node emits timeout when its time runs outYou can inspect and listen to these built-in signals either from the editor's 'Node' dock or directly through code.
Other common built-in signals
Built-in signals are tailored to different node types. For Area2D, body_entered is reported when a physics body enters the area; LineEdit fires text_changed when text is modified.
# When an object collides with Area2D:
# body_entered(body: Node2D)
# When text is entered in LineEdit:
# text_changed(new_text: String)These signals automatically pass relevant arguments (like the colliding body) to the listener.
Practice Report built-in signal
Define a _ready function. Inside, print the text "Buton sinyali: pressed" using print.
Starter code
extends Node
# _ready fonksiyonunu tanimla ve sinyali yazdirSample solution
extends Node
func _ready():
print("Buton sinyali: pressed")Expected output
Buton sinyali: pressed
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which built-in signal is triggered when a Button node is clicked with the mouse?
- mouse_hit
- trigger_on
- pressed Correct answer
- clicked_now
Explanation: In Godot, the standard click signal for BaseButton and Button classes is named 'pressed'.
2 Access button signal
var btn = Button.new()
# Buton tiklama sinyalinin adi
var sinyal_adi = btn.____.name
var btn = Button.new()
# Buton tiklama sinyalinin adi
var sinyal_adi = btn.pressed.name
Explanation: The built-in signal of a Button node is defined as 'pressed'.
3 Node and built-in signal match
| Term | Meaning |
|---|---|
Button |
pressed |
Timer |
timeout |
Area2D |
body_entered |
LineEdit |
text_changed |