メインコンテンツへスキップ

Godot - ゲーム退出ボタン

·47 文字
icysamon
著者
icysamon
電子工作・クリエイター
# Godot 4.1

extends Node

@onready var exit_but = Button


func _ready():
    exit_but = get_node("Button")
    exit_but.pressed.connect(self._button_pressed)


# ボタンが押されたとき
func _button_pressed():
    get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)


# ゲームを終了
func _notification(what):
    if what == NOTIFICATION_WM_CLOSE_REQUEST:
        get_tree().quit() # default behavior