若无特殊说明,默认是在script.rpy
文件中进行编写
参考资料
Ren’py官方文档相关链接:
- 画廊
- 常规解锁判断
- 周目解锁判断
视频教程
基础部分
进阶操作
前提条件
同音乐空间一样,想要实现画廊需要一些前提条件,详见下述代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
image gallery_background: "gallery_background.png" size (1920, 1080)
init python:
g = Gallery()
g.button("bg") g.image("bg01.png") g.unlock_image("bg03.png")
g.button("cg") g.condition("persistent.unlock_1") g.image("cg01.png")
g.button("unlock")
g.transition = dissolve
default p = ui.adjustment()
|
界面编写
前提条件编写完成后,我们就可以着手编写画廊界面了,这里我提供了滚动条样式和翻页样式两种常用形式,请自行选择你想要那种效果
滚动条式界面(推荐)
以下代码适用于滚动条式界面,请选择好你想要的效果。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
screen gallery:
tag menu add "gallery_background"
vbar: xysize (10, 680) align (0.9, 0.5) value YScrollValue("cg_list")
viewport id "cg_list": mousewheel True xysize (1500, 680) align (0.5, 0.5) draggable True yadjustment p
vbox: spacing 60
text "角色1" size 40 grid 4 3 id "bg": spacing 60
if renpy.seen_image("bg05"): add g.make_button("bg", "smbg03.png") else: add g.make_button("unlock", "unknow.png") if renpy.seen_image("bg03"): add g.make_button("bg", "smbg03.png") else: add g.make_button("unlock", "unknow.png") if renpy.seen_image("bg03"): add g.make_button("bg", "smbg03.png") else: add g.make_button("unlock", "unknow.png") if renpy.seen_image("bg03"): add g.make_button("bg", "smbg03.png") else: add g.make_button("unlock", "unknow.png")
add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png")
add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png")
text "角色2" size 40
grid 4 3 id "cg": spacing 60 add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png")
add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png")
add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png")
vbox: textbutton "角色1" action Function(p.change,0) textbutton "角色2" action Function(p.change,799)
textbutton "返回": align (0.0, 0.98) action Return()
|
翻页式界面
以下代码适用于翻页式界面,请选择好你想要的效果。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| screen gallery(page=0):
tag menu add "gallery_background" viewport: xysize (1500, 680) align (0.5, 0.5)
vbox: spacing 60 if (page == 0): grid 3 1: spacing 60 add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png")
if (page == 1): grid 3 1: spacing 60 add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png")
if (page == 2): grid 3 1: spacing 60 add g.make_button("cg", "smcg01.png") add g.make_button("cg", "smcg01.png") add g.make_button("cg", "smcg01.png")
hbox: xalign 0.5 yalign 0.9 spacing 60 if page < 2: textbutton "下一页" action Show("gallery",page=(page+1)) else: textbutton "下一页" action NullAction()
textbutton "1" action Show("gallery",page=0) textbutton "2" action Show("gallery",page=1) textbutton "3" action Show("gallery",page=2) if page > 0: textbutton "上一页" action Show("gallery",page=(page-1)) else: textbutton "上一页" action NullAction()
textbutton "返回": align (0.0, 0.98) action Return()
|
如果想添加快速定位功能,请进一步定义角色名_page
,并修改为以下代码(只显示需要修改的代码)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| screen gallery(角色1_page=0)
viewport: xysize (1500, 680) align (0.5, 0.5)
vbox: spacing 60 if (角色1_page == 0): grid 3 1: spacing 60 add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") vbox: textbutton "下一页" action Show("gallery",角色1_page=(角色1_page+1)) textbutton "上一页" action Show("gallery",角色1_page=(角色1_page-1))
if (角色1_page == 1): grid 3 1: spacing 60 add g.make_button("bg", "smbg03.png") add g.make_button("bg", "smbg03.png") add g.make_button("cg", "smcg01.png") vbox: textbutton "下一页" action Show("gallery",角色1_page=(角色1_page+1)) textbutton "上一页" action Show("gallery",角色1_page=(角色1_page-1))
if (角色2_page=0): grid 3 1: spacing 60 add g.make_button("cg", "smcg01.png") add g.make_button("cg", "smcg01.png") add g.make_button("cg", "smcg01.png") vbox: textbutton "下一页" action Show("gallery",角色2_page=(角色2_page+1)) textbutton "上一页" action Show("gallery",角色2_page=(角色2_page-1))
vbox: textbutton "角色1" action Show("gallery",角色1_page=0) textbutton "角色2" action Show("gallery",角色2_page=0)
|
周目解锁
添加如下代码:
1 2 3 4
| init python: if persistent.unlock_1 == None: persistent.unlock_1 ==False
|
在某一结局内添加如下代码:
1 2 3
| $ persistent.unlock_1 = True
|
添加入口
完成上述操作后,我们还需要添加主界面进入按钮,打开screens.rpy
,找到screen navigation()
(287行左右),在合适位置添加下面的代码
1
| textbutton "画廊" action ShowMenu("gallery")
|
现在运行游戏,即可在主界面看到画廊进入按钮,请检查各功能是否可用。