Files
spellforge/scenes/ui/splash.gd
T
2026-07-20 10:56:52 +08:00

92 lines
2.8 KiB
GDScript

## 启动画面:公司/游戏商标 + 引擎版权 → 自动跳转主菜单
extends Control
const HOLD_SEC: float = 1.8 # 完全显示后停留时长
var _timer: float = 0.0
var _skip_ready: bool = false # 防止首帧立即跳过
func _ready() -> void:
SceneManager.fade_in_first()
_build_ui()
# 延迟一帧后才允许跳过(防止启动时按键残留)
call_deferred("_allow_skip")
func _allow_skip() -> void:
_skip_ready = true
func _build_ui() -> void:
# 全屏渐变背景
var bg := ColorRect.new()
bg.color = Color(0.04, 0.04, 0.09)
bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
add_child(bg)
# 工作室名
var studio := Label.new()
studio.text = "LANTERN GAMES"
studio.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
studio.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
studio.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
studio.position.y = -80
studio.add_theme_font_size_override("font_size", 18)
studio.modulate = Color(0.7, 0.7, 0.7)
add_child(studio)
# 游戏标题
var title := Label.new()
title.text = "魔法工匠"
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
title.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
title.add_theme_font_size_override("font_size", 64)
title.modulate = Color(1.0, 0.85, 0.3)
add_child(title)
# 英文副标题
var sub := Label.new()
sub.text = "Arcane Artificer"
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
sub.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
sub.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
sub.position.y = 64
sub.add_theme_font_size_override("font_size", 22)
sub.modulate = Color(0.7, 0.75, 1.0)
add_child(sub)
# 提示
var hint := Label.new()
hint.text = tr("SPLASH_SKIP_HINT")
hint.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
hint.set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
hint.position.y = -40
hint.add_theme_font_size_override("font_size", 13)
hint.modulate = Color(0.5, 0.5, 0.5)
add_child(hint)
# 版权
var copy := Label.new()
copy.text = "© 2026 Lantern Games | Powered by Godot 4.6"
copy.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
copy.set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
copy.position.y = -16
copy.add_theme_font_size_override("font_size", 11)
copy.modulate = Color(0.4, 0.4, 0.4)
add_child(copy)
func _process(delta: float) -> void:
_timer += delta
if _timer >= HOLD_SEC:
_go_to_menu()
func _input(event: InputEvent) -> void:
if not _skip_ready:
return
if event.is_action_pressed("ui_accept") or event.is_action_pressed("ui_cancel") \
or (event is InputEventMouseButton and event.pressed):
_go_to_menu()
func _go_to_menu() -> void:
set_process(false)
set_process_input(false)
SceneManager.goto_main_menu()