浏览代码

:lipstick: Create a simple menu

DricomDragon 2 年之前
父节点
当前提交
7d0763a22e

+ 14 - 0
godot/component/ui/launcher/launcher.gd

@@ -0,0 +1,14 @@
+extends Button
+
+
+@export var level: PackedScene
+
+
+func _on_pressed():
+	launch_level()
+
+
+func launch_level():
+	assert(level, "A level must be specified in the editor")
+	var err = get_tree().change_scene_to_packed(level)
+	assert(!err)

+ 15 - 0
godot/component/ui/launcher/launcher.tscn

@@ -0,0 +1,15 @@
+[gd_scene load_steps=2 format=3 uid="uid://xa6opw1e34ve"]
+
+[ext_resource type="Script" path="res://component/ui/launcher/launcher.gd" id="1_om81t"]
+
+[node name="Launcher" type="Button"]
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_font_sizes/font_size = 50
+text = "Level name"
+script = ExtResource("1_om81t")
+
+[connection signal="pressed" from="." to="." method="_on_pressed"]

+ 1 - 1
godot/project.godot

@@ -21,7 +21,7 @@ _global_script_class_icons={
 [application]
 
 config/name="StarKiss"
-run/main_scene="res://levels/world.tscn"
+run/main_scene="res://run/menu.tscn"
 config/features=PackedStringArray("4.0", "Mobile")
 config/icon="res://icon.svg"
 

godot/levels/heart.tscn → godot/run/levels/heart.tscn


godot/levels/simple_scales.tscn → godot/run/levels/simple_scales.tscn


godot/levels/world.tscn → godot/run/levels/world.tscn


+ 78 - 0
godot/run/menu.tscn

@@ -0,0 +1,78 @@
+[gd_scene load_steps=5 format=3 uid="uid://yi5bab38nsy1"]
+
+[ext_resource type="PackedScene" uid="uid://xa6opw1e34ve" path="res://component/ui/launcher/launcher.tscn" id="1_drwug"]
+[ext_resource type="PackedScene" uid="uid://bs8crkburdpjc" path="res://run/levels/world.tscn" id="2_x8xps"]
+[ext_resource type="PackedScene" uid="uid://bwvywnh4itqg3" path="res://run/levels/simple_scales.tscn" id="3_xung6"]
+[ext_resource type="PackedScene" uid="uid://38l0xifohua4" path="res://run/levels/heart.tscn" id="4_wmep8"]
+
+[node name="Menu" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="Title" type="RichTextLabel" parent="."]
+layout_mode = 1
+anchors_preset = -1
+anchor_left = 0.5
+anchor_right = 0.5
+offset_left = -240.0
+offset_top = 20.0
+offset_right = 240.0
+offset_bottom = 180.0
+grow_horizontal = 2
+theme_override_font_sizes/normal_font_size = 110
+text = "Star Kiss"
+scroll_active = false
+
+[node name="LevelScroll" type="ScrollContainer" parent="."]
+layout_mode = 1
+anchors_preset = -1
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_left = 20.0
+offset_top = 200.0
+offset_right = -20.0
+offset_bottom = -20.0
+horizontal_scroll_mode = 0
+
+[node name="LevelContainer" type="VBoxContainer" parent="LevelScroll"]
+layout_mode = 2
+offset_right = 302.0
+offset_bottom = 239.0
+alignment = 1
+
+[node name="SimpleLevel" parent="LevelScroll/LevelContainer" instance=ExtResource("1_drwug")]
+layout_mode = 2
+anchors_preset = 0
+anchor_right = 0.0
+anchor_bottom = 0.0
+offset_right = 302.0
+offset_bottom = 77.0
+text = "Basic test
+"
+level = ExtResource("2_x8xps")
+
+[node name="ScaleLevel" parent="LevelScroll/LevelContainer" instance=ExtResource("1_drwug")]
+layout_mode = 2
+anchors_preset = 0
+anchor_right = 0.0
+anchor_bottom = 0.0
+offset_top = 81.0
+offset_right = 302.0
+offset_bottom = 158.0
+text = "Scale test"
+level = ExtResource("3_xung6")
+
+[node name="HeartLevel" parent="LevelScroll/LevelContainer" instance=ExtResource("1_drwug")]
+layout_mode = 2
+anchors_preset = 0
+anchor_right = 0.0
+anchor_bottom = 0.0
+offset_top = 162.0
+offset_right = 302.0
+offset_bottom = 239.0
+text = "Heart music"
+level = ExtResource("4_wmep8")