# Godot 4.1
extends Node
@onready var exit_but = Button
func _ready():
exit_but = get_node("Button")
exit_but.pressed.connect(self._button_pressed)
# When the button is pressed
func _button_pressed():
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
# Quit the game
func _notification(what):
if what == NOTIFICATION_WM_CLOSE_REQUEST:
get_tree().quit() # default behaviorGodot - Game Exit Button
·39 words