Hide the debug fly and level skip behind a 房★主★有★神★器★ easter-egg panel

cheat_panel replaces the level_skip autoload: a single small button in the top-right opens a panel holding the fly toggle and the level jump buttons, so nothing that looks like leftover debug UI is on screen. The fly is no longer gated behind OS.is_debug_build, so the easter egg works in exported builds too, and the 1/2/3 shortcuts only fire while the panel is open so they cannot be hit by accident. Space stays unbound and no gameplay content was touched.
This commit is contained in:
2026-10-07 23:10:41 +08:00
parent 44e4c3a751
commit f549c03533
8 changed files with 208 additions and 100 deletions
+111
View File
@@ -0,0 +1,111 @@
extends CanvasLayer
## 「房★主★有★神★器★」:把两个调试功能(飞行 / 跳关)藏在一个彩蛋按钮里。
##
## 平时屏幕上只有右上角一个小小的「房★主★有★神★器★」按钮,
## 点一下才弹出面板,里面是飞行开关和跳关按钮。
## 面板打开时键盘 1/2/3 也能跳关,Esc 或再点一次按钮关闭。
## 正式版里也能用(这是刻意留的彩蛋,不是调试残留)。
@export var levels: Array[String] = [
"res://scenes/main.tscn",
"res://scenes/level2.tscn",
"res://scenes/level3.tscn",
]
## 是否显示那个彩蛋按钮(关掉的话就只能靠别的方式打开面板了)
@export var show_button: bool = true
var _panel: Control = null
var _open_button: Button = null
var _fly_button: Button = null
var _player: Node = null
var _open: bool = false
func _ready() -> void:
visible = true
_panel = get_node_or_null("Panel")
_open_button = get_node_or_null("OpenButton")
_fly_button = get_node_or_null("Panel/VBox/FlyButton")
if _open_button != null:
_open_button.visible = show_button
_open_button.pressed.connect(toggle_panel)
var close := get_node_or_null("Panel/VBox/CloseButton")
if close != null:
close.pressed.connect(toggle_panel)
if _fly_button != null:
_fly_button.pressed.connect(toggle_fly)
var row := get_node_or_null("Panel/VBox/Row")
if row != null:
var index := 1
for path in levels:
var btn := Button.new()
btn.text = str(index)
btn.custom_minimum_size = Vector2(26.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))
row.add_child(btn)
index += 1
if _panel != null:
_panel.visible = false
func _process(_delta: float) -> void:
if _fly_button == null:
return
if _player == null or not is_instance_valid(_player):
_player = get_tree().get_first_node_in_group("player")
if _player == null:
_fly_button.text = "飞行(F)"
return
_fly_button.text = "飞行:开(F)" if bool(_player.flying) else "飞行:关(F)"
func _unhandled_input(event: InputEvent) -> void:
if not _open:
return
var key := event as InputEventKey
if key == null or not key.pressed or key.echo:
return
if key.physical_keycode == KEY_ESCAPE:
toggle_panel()
return
var n := 0
match key.physical_keycode:
KEY_1:
n = 1
KEY_2:
n = 2
KEY_3:
n = 3
KEY_4:
n = 4
KEY_5:
n = 5
if n >= 1 and n <= levels.size():
jump_to(levels[n - 1])
func toggle_panel() -> void:
_open = not _open
if _panel != null:
_panel.visible = _open
func toggle_fly() -> void:
if _player == null or not is_instance_valid(_player):
_player = get_tree().get_first_node_in_group("player")
if _player == null or not _player.has_method("set_flying"):
return
_player.set_flying(not bool(_player.flying))
func jump_to(path: String) -> void:
get_tree().paused = false
get_tree().change_scene_to_file(path)
-59
View File
@@ -1,59 +0,0 @@
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)
+7 -3
View File
@@ -357,7 +357,8 @@ func _build_throw_visuals() -> void:
# ---------------------------------------------------------------- 测试用飞行
func fly_available() -> bool:
return debug_fly and OS.is_debug_build()
# 这是藏在「房★主★有★神★器★」面板里的隐藏技能,正式版里也能用
return debug_fly
func set_flying(on: bool) -> void:
@@ -368,10 +369,13 @@ func set_flying(on: bool) -> void:
func handle_fly_movement() -> void:
# get_axis(负方向, 正方向),屏幕坐标里 y 向下为正,所以空格(跳跃)要放在负方向
# 跳跃键已经停用了,所以调试飞行改用方向键上下(S 也保留作下降)来控制升降
var vertical := Input.get_axis("ui_up", "ui_down")
if is_zero_approx(vertical) and Input.is_action_pressed("squat"):
vertical = 1.0
var direction := Vector2(
Input.get_axis("move_left", "move_right"),
Input.get_axis("jump", "squat")
vertical
)
if direction == Vector2.ZERO:
velocity = Vector2.ZERO