From 201ddb359f032cf207de1a00a491ac0ccafe6bae Mon Sep 17 00:00:00 2001 From: Bunnycxk <986826561@qq.com> Date: Sun, 28 Jan 2024 02:52:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E7=BC=BA=E7=BA=B9=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objects/main_menu/main_menu.gd | 7 ++++++- objects/main_menu/main_menu.tscn | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/objects/main_menu/main_menu.gd b/objects/main_menu/main_menu.gd index 69af37b..48b9e54 100644 --- a/objects/main_menu/main_menu.gd +++ b/objects/main_menu/main_menu.gd @@ -1,5 +1,6 @@ extends AnimatedSprite2D +var ChapterMenu = preload("res://levels/chapter_menu/chapter_menu.tscn") # Called when the node enters the scene tree for the first time. func _ready(): @@ -15,4 +16,8 @@ func _process(delta): func _on_animation_finished(): play("wait_for_start") - pass # Replace with function body. + + +func _on_start_button_pressed(): + get_tree().root.add_child(ChapterMenu.instantiate()) + queue_free() diff --git a/objects/main_menu/main_menu.tscn b/objects/main_menu/main_menu.tscn index 6e34776..ff0e113 100644 --- a/objects/main_menu/main_menu.tscn +++ b/objects/main_menu/main_menu.tscn @@ -81,4 +81,11 @@ sprite_frames = SubResource("SpriteFrames_b4517") centered = false script = ExtResource("14_npy3s") +[node name="start_button" type="Button" parent="."] +offset_left = 88.8 +offset_top = 76.8 +offset_right = 104.8 +offset_bottom = 92.8 + [connection signal="animation_finished" from="." to="." method="_on_animation_finished"] +[connection signal="pressed" from="start_button" to="." method="_on_start_button_pressed"]