本文最后更新于 43 天前,如有失效请评论区留言。
参考文档:
renpy官方文档:https://doc.renpy.cn/zh-CN/gui.html
Ren’Py引擎从入门到放弃(15)——GUI定制化之主菜单:
https://www.renpy.cn/thread-733-1-1.html
使用Renpy引擎打造Nvl游戏 (三):制作自己的GUI
前言
在经过过了第一章和第二章的学习,我们可以开始着手打造GUI了。
我是受到了月姬的启发,所以GUI方面也是准备往那一边靠拢。
也就是传统的NVL模式。
正式开始
爱丽丝的GUI
先来看看爱丽丝的GUI初稿。
## 标题菜单屏幕 ######################################################################
##
## 用于在 Ren'Py 启动时显示标题菜单。
##
## https://doc.renpy.cn/zh-CN/screen_special.html#main-menu
transform main_menu_button_in(delay):
# 图片宽度273,所以默认偏移量稍微多两个像素
xoffset 2750
on start:
time delay
easein_quint 2.0 xoffset 0
transform main_menu_button_hover:
on hover:
ease 0.5 xoffset -35
on idle:
ease 0.5 xoffset 0
screen main_menu():
tag menu
add gui.main_menu_background
vbox:
xalign 0.5
yalign 0.95
frame:
# 无背景
background None
# 不扩展
padding (0, 0, 0, 0)
imagebutton:
idle "gui/button/main_menu_button.png"
foreground "new_game_button_text"
activate_sound "audio/choose.ogg"
at main_menu_button_hover
action Start()
at main_menu_button_in(1.2)
frame:
background None
padding (0, 0, 0, 0)
imagebutton:
idle "gui/button/main_menu_button.png"
foreground "load_game_button_text"
activate_sound "audio/choose.ogg"
at main_menu_button_hover
action ShowMenu("load")
at main_menu_button_in(0.9)
frame:
background None
padding (0, 0, 0, 0)
imagebutton:
idle "gui/button/main_menu_button.png"
foreground "preference_button_text"
activate_sound "audio/choose.ogg"
at main_menu_button_hover
action ShowMenu("preferences")
at main_menu_button_in(0.6)
frame:
background None
padding (0, 0, 0, 0)
imagebutton:
idle "gui/button/main_menu_button.png"
foreground "quit_button_text"
activate_sound "audio/choose.ogg"
at main_menu_button_hover
action Quit(confirm=not main_menu)
at main_menu_button_in(0.3)
# 文字本体样式
style main_menu_button_text_fill:
align (0.5, 0.5)
size 30
# font ""
color "#fedaaa"
outlines [(1, "#fab5a4", 0, 0)]
# 文字投影样式
style main_menu_button_text_shadow:
align (0.5, 0.5)
size 30
# font ""
color "#c0c0c0"
outlines [(2, "#c0c0c0", 3, 3)]
image new_game_button_text:
contains:
Text("开始游戏", style = "main_menu_button_text_shadow")
contains:
Text("开始游戏", style = "main_menu_button_text_fill")
image load_game_button_text:
contains:
Text("继续游戏", style = "main_menu_button_text_shadow")
contains:
Text("继续游戏", style = "main_menu_button_text_fill")
image preference_button_text:
contains:
Text("设置", style = "main_menu_button_text_shadow")
contains:
Text("设置", style = "main_menu_button_text_fill")
image quit_button_text:
contains:
Text("放弃", style = "main_menu_button_text_shadow")
contains:
Text("放弃", style = "main_menu_button_text_fill")
style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text
style main_menu_frame:
xsize 420
yfill True
background "gui/overlay/main_menu.png"
style main_menu_vbox:
xalign 1.0
xoffset -30
xmaximum 1200
yalign 1.0
yoffset -30
style main_menu_text:
properties gui.text_properties("main_menu", accent=True)
style main_menu_title:
properties gui.text_properties("title")
style main_menu_version:
properties gui.text_properties("version")