Transitions
本页属于 GenPy Ren'Py 学习路线。教程内容面向 Ren'Py 8.x,并在页面末尾连接到 GenPy 的对应工作流。
学习目标
- 了解“Transitions”在 Ren'Py 项目中的用途。
- 能在一个最小项目里验证本章相关语法或工作流。
- 知道发布前需要检查的常见风险,并能在 GenPy 中继续维护。
核心语法
withdissolvefademovetransition
可运行示例
text
define slow_dissolve = Dissolve(2.0) # 2 秒溶解
define long_fade = Fade(0.5, 0.0, 0.5) # 出/停/入
define pix = Pixellate(1.0, 5)
label start:
scene bg room
with slow_dissolve教程正文
转场(Transition)是画面切换时的过渡动画。用 with 语句或 show ... with 应用。
1. with 语句
with 对“到此为止累计的画面改动”整体应用一个转场:
text
scene bg room
show eileen happy
with dissolve # 上面这些改动一起以 dissolve 呈现
scene bg night
with fade # 黑场过渡with None(落定当前画面)
with None 不做动画,但会把“当前画面状态”立即定格,常用于把多步拆成两段转场:
text
scene bg room
show eileen
with None # 先无动画落定
show lucy
with dissolve # 只让 lucy 溶解出现2. 内置转场速查
| 名称 | 效果 |
|---|---|
dissolve | 交叉溶解 |
fade | 淡出到黑再淡入 |
pixellate | 像素化过渡 |
move | 位置变化的对象平滑移动 |
moveinright / moveinleft / moveintop / moveinbottom | 从某方向移入 |
moveoutright / moveoutleft / ... | 向某方向移出 |
ease、easeinright 等 | 带缓动的移入移出 |
wipeleft / wiperight / wipeup / wipedown | 擦除 |
slideleft / slideright / ... | 滑动 |
pushright / pushleft / ... | 推挤 |
vpunch / hpunch | 垂直/水平震屏 |
blinds | 百叶窗 |
squares | 方块 |
zoomin / zoomout / zoominout | 缩放过渡 |
text
show eileen happy
with moveinright
scene bg boom
with vpunch # 震一下3. 自定义转场(用转场类)
用 define 配置参数化的转场类,得到可复用的转场对象:
text
define slow_dissolve = Dissolve(2.0) # 2 秒溶解
define long_fade = Fade(0.5, 0.0, 0.5) # 出/停/入
define pix = Pixellate(1.0, 5)
label start:
scene bg room
with slow_dissolve常用转场类
| 类 | 说明 |
|---|---|
Dissolve(time) | 溶解 |
Fade(out, hold, in, color="#000") | 淡出-保持-淡入 |
Pixellate(time, steps) | 像素化 |
MoveTransition(time, ...) | 移动转场(对象平滑到新位置) |
ImageDissolve(image, time) | 按灰度图遮罩溶解(做花式擦除) |
CropMove(time, mode) | 裁剪移动(百叶窗/擦除等的底层) |
ComposeTransition(...) | 组合多个转场 |
MultipleTransition([...]) | 串联多段转场 |
AlphaDissolve(...) | 用动画控制的 alpha 溶解 |
ImageDissolve(遮罩溶解,做高级擦除)
text
define heart_wipe = ImageDissolve("masks/heart.png", 1.5)
# 灰度图决定溶解顺序:黑先白后4. 只对某图层应用转场
转场可针对图层字典:
text
define dis = { "master" : Dissolve(1.0) }
show eileen
with dis # 只让 master 层溶解,UI 层不受影响5. 窗口显示/隐藏转场
对话框出现/消失的过渡:
text
define config.window_show_transition = Dissolve(0.25)
define config.window_hide_transition = Dissolve(0.25)6. 在 ATL 里做“转场”
复杂入场可直接用 ATL(见第 11 章),比固定转场更灵活:
text
show eileen happy:
alpha 0.0 yoffset 50
parallel:
linear 0.4 alpha 1.0
parallel:
ease 0.4 yoffset 0常见坑
with作用于累计改动:把要一起过渡的 show/scene 放在同一个 with 前。- 想分两段过渡时用
with None先定格。 Dissolve等是类(大写、带参数),dissolve是预定义实例(小写)。- 过渡时间过长会拖慢节奏;常用 0.3~0.5s。
官方参考
在 GenPy 里怎么做
- 在 GenPy 的代码模式中维护相关 .rpy 文件,先保持语法清晰,再逐步加入本章功能。
- 用故事图谱、变量、校验或演出编辑器把“能运行”提升到“可维护”。
- 导出前结合 Ren'Py Lint 和 GenPy 校验结果,确认脚本、素材和发布路径一致。
推荐继续阅读:
