浏览代码

:tada: Plug the title screen in the game

DricomDragon 1 年之前
父节点
当前提交
03cf7f2b25

+ 4 - 1
godot/component/ui/title/title_screen.gd

@@ -1,13 +1,16 @@
 extends VSplitContainer
 
 
+signal start_game
+
 
 func _ready() -> void:
 	%StartButton.grab_focus()
 
 
 func _on_start_button_pressed():
-	print("start")
+	start_game.emit()
+	queue_free()
 
 
 func _on_quit_button_pressed():

+ 9 - 0
godot/flow/control/local_input/local_input.gd

@@ -6,6 +6,7 @@ signal dir_changed(new_dir: Vector2)
 signal main_action(pressed: bool)
 signal get_in_action(commander: LocalInput)
 
+
 func _unhandled_input(event: InputEvent) -> void:
 	if event.is_action("main"):
 		main_action.emit(event.is_pressed())
@@ -14,3 +15,11 @@ func _unhandled_input(event: InputEvent) -> void:
 	elif event.is_action("move_left") or event.is_action("move_right") or event.is_action("move_back") or event.is_action("move_forward"):
 		var dir: Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward")
 		dir_changed.emit(dir)
+
+
+func _on_title_screen_start_game() -> void:
+	_enable()
+
+
+func _enable() -> void:
+	set_process_mode(Node.PROCESS_MODE_PAUSABLE)

+ 6 - 1
godot/run/levels/infinite_level.tscn

@@ -1,4 +1,4 @@
-[gd_scene load_steps=16 format=3 uid="uid://7ivipmwaw24t"]
+[gd_scene load_steps=17 format=3 uid="uid://7ivipmwaw24t"]
 
 [ext_resource type="Texture2D" uid="uid://cgwafs6ukpm7y" path="res://component/entity/ground/ground051.jpg" id="1_3ytcp"]
 [ext_resource type="Script" path="res://run/levels/camera_tracker.gd" id="1_qdm47"]
@@ -12,6 +12,7 @@
 [ext_resource type="Script" path="res://flow/music_player/music_player.gd" id="8_iulsm"]
 [ext_resource type="AudioStream" uid="uid://c3l60bt307wjh" path="res://flow/music_player/00-Wesh-tone-realaze.mp3" id="8_ndffw"]
 [ext_resource type="PackedScene" uid="uid://bwhwbm6jrvg42" path="res://component/entity/buildings/outer_stairs_house/outer_stairs_house.tscn" id="11_j8m6y"]
+[ext_resource type="PackedScene" uid="uid://uy3pgfv4q3iy" path="res://component/ui/title/title_screen.tscn" id="13_2xijd"]
 
 [sub_resource type="BoxShape3D" id="BoxShape3D_ctk0t"]
 size = Vector3(500, 10, 500)
@@ -54,6 +55,7 @@ camera_height = 2.0
 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.0852, 1.31191, -4.00841)
 
 [node name="Control" parent="MainWalker" instance=ExtResource("2_0i5t8")]
+process_mode = 4
 
 [node name="Props" type="Node3D" parent="."]
 
@@ -147,9 +149,12 @@ transform = Transform3D(4.37114e-08, 0, 1, 0, 1, 0, 1, 0, -4.37114e-08, 62.7817,
 [node name="StairHouse5" parent="Buildings" instance=ExtResource("11_j8m6y")]
 transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 62.7817, 0, 32.8533)
 
+[node name="TitleScreen" parent="." instance=ExtResource("13_2xijd")]
+
 [connection signal="focus_required" from="MainWalker" to="CameraTracker" method="_on_focus_required"]
 [connection signal="got_in" from="MainWalker" to="MusicPlayer" method="_on_driver_got_in"]
 [connection signal="got_out" from="MainWalker" to="MusicPlayer" method="_on_driver_got_out"]
 [connection signal="dir_changed" from="MainWalker/Control" to="MainWalker" method="_on_dir_changed"]
 [connection signal="get_in_action" from="MainWalker/Control" to="MainWalker" method="_on_get_in_action"]
 [connection signal="main_action" from="MainWalker/Control" to="MainWalker" method="_on_main_action"]
+[connection signal="start_game" from="TitleScreen" to="MainWalker/Control" method="_on_title_screen_start_game"]