Add a debug-only level skip overlay so testing level 3 does not require beating levels 1 and 2

Registered as an autoload so every scene gets it for free. Top-right shows a row of buttons generated from the levels array (main, level2, level3) plus keyboard shortcuts 1/2/3, and it runs with PROCESS_MODE_ALWAYS at layer 30 so it still works while the tree is paused on a death or level-clear screen. Hidden in exported release builds, same rule as the debug flight.
This commit is contained in:
2026-10-07 23:02:57 +08:00
parent 8127c787f8
commit 44e4c3a751
3 changed files with 92 additions and 0 deletions
+4
View File
@@ -15,6 +15,10 @@ run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
LevelSkip="*res://scenes/level_skip.tscn"
[display]
window/size/viewport_width=468
+29
View File
@@ -0,0 +1,29 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Script" path="res://scripts/level_skip.gd" id="1_skip"]
[sub_resource type="SystemFont" id="SystemFont_cjk"]
font_names = PackedStringArray("Microsoft YaHei UI", "Microsoft YaHei", "SimHei", "Noto Sans CJK SC", "sans-serif")
[node name="LevelSkip" type="CanvasLayer"]
process_mode = 3
layer = 30
script = ExtResource("1_skip")
[node name="Buttons" type="HBoxContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -130.0
offset_top = 6.0
offset_right = -6.0
offset_bottom = 32.0
theme_override_constants/separation = 4
[node name="Hint" type="Label" parent="Buttons"]
theme_override_colors/font_color = Color(1, 1, 1, 0.85)
theme_override_colors/font_outline_color = Color(0, 0, 0, 0.8)
theme_override_constants/outline_size = 3
theme_override_fonts/font = SubResource("SystemFont_cjk")
theme_override_font_sizes/font_size = 11
text = "跳关"
vertical_alignment = 1
+59
View File
@@ -0,0 +1,59 @@
extends CanvasLayer
## 测试用跳关:右上角一排数字按钮,点一下直接跳到对应关卡;
## 键盘上按 1 / 2 / 3 也一样。
## 只在编辑器 / 调试版里显示,导出的正式版会自动隐藏(和飞行一个规矩)。
@export var levels: Array[String] = [
"res://scenes/main.tscn",
"res://scenes/level2.tscn",
"res://scenes/level3.tscn",
]
## 强制在正式版里也显示(一般别开)
@export var always_show: bool = false
func _ready() -> void:
visible = always_show or OS.is_debug_build()
if not visible:
set_process_unhandled_input(false)
return
var box := get_node_or_null("Buttons")
if box == null:
return
var index := 1
for path in levels:
var btn := Button.new()
btn.text = str(index)
btn.custom_minimum_size = Vector2(24.0, 24.0)
btn.focus_mode = Control.FOCUS_NONE
btn.add_theme_font_size_override("font_size", 12)
btn.pressed.connect(jump_to.bind(path))
box.add_child(btn)
index += 1
func _unhandled_input(event: InputEvent) -> void:
var key := event as InputEventKey
if key == null or not key.pressed or key.echo:
return
var n := 0
match key.physical_keycode:
KEY_1, KEY_KP_1:
n = 1
KEY_2, KEY_KP_2:
n = 2
KEY_3, KEY_KP_3:
n = 3
KEY_4, KEY_KP_4:
n = 4
KEY_5, KEY_KP_5:
n = 5
if n >= 1 and n <= levels.size():
jump_to(levels[n - 1])
func jump_to(path: String) -> void:
get_tree().paused = false
get_tree().change_scene_to_file(path)