You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ren'Py屏幕返回问题求助:如何实现从自定义屏幕返回对话

解决Ren'Py视觉小说的屏幕返回问题

你的代码存在几个关键问题导致无法正常返回主线,以下是修正方案:

问题分析

  • 屏幕内不能使用call label Return这类语法,Ren'Py的屏幕交互逻辑需要通过动作(Action)来处理。
  • Show("CorpseText")仅能显示文本屏幕,但未设置关闭该屏幕并回到主线的交互逻辑。
  • 主线里的label Return属于冗余定义,且位置不符合流程要求。

修正后的完整代码

screen CorpseText():
    frame:
        xalign 0.5
        yalign 0.5
        text "barn är jobbiga"
        # 添加关闭按钮,点击后隐藏屏幕并返回主线
        textbutton "关闭" xalign 0.5 yalign 1.0 action [Hide("CorpseText"), Return()]

screen Lik():
    imagebutton:
        xalign 0.5
        yalign 0.5
        idle "bg williamdedlolclose"
        action Show("CorpseText")

label start:
    scene bg williamdedlol
    "click on the body"
    # call screen会暂停主线,直到屏幕执行Return()后恢复
    call screen Lik
    # 屏幕返回后直接执行后续对话
    "(His back has been broken from the fall and like Manea said, it looks like he’s been stabbed in the face.)"

关键修改说明

  1. CorpseText屏幕优化:
    添加的textbutton通过Hide("CorpseText")隐藏自身,再用Return()结束call screen的暂停状态,让流程回到主线。如果想实现点击任意区域关闭,可替换为全屏透明按钮:
    screen CorpseText():
        # 全屏透明点击区域,点击任意位置关闭并返回
        button:
            xfill True
            yfill True
            action [Hide("CorpseText"), Return()]
        frame:
            xalign 0.5
            yalign 0.5
            text "barn är jobbiga"
    
  2. 主线逻辑精简:
    移除了多余的label Return,call screen Lik会在屏幕执行Return()后自动继续后续代码,完全匹配你预期的流程。

内容的提问来源于stack exchange,提问作者Hugge

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 19:32:07