找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 22436|回复: 7

[已解决] 在跳转到第二个rpy内的screen以后,如何使按钮具备返回功能

[复制链接]
发表于 2021-4-24 21:49:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我现在script.rpy写了一个选择界面,由此进入第二个science.rpy 里面的screen science选择界面。
我想添加一个返回按钮的imagebutton,对于返回按钮我进行的操作是action Return(),实际点击以后,并没有返回到第一个选择页面,而是继续进行到了label phy1
其他的按钮都工作正常,而且因为我想做一个重复的养成界面,所以不能直接用jump"screen2",这样就无法推进时间线了。。
求大佬们教教,真的感谢了

第二个界面的选择部分代码

第二个界面的选择部分代码

在script定义的第一个主菜单界面,由此打开第二个界面的选择

在script定义的第一个主菜单界面,由此打开第二个界面的选择
发表于 2021-4-25 11:29:09 | 显示全部楼层
如果搞不清逻辑,建议用笨办法。
就是完成第一个screen之后,先jump到一个label里,这个label里面就一句话,call之后想要的的screen。
回复 支持 1 抱歉 0

使用道具 举报

发表于 2021-4-25 08:48:28 | 显示全部楼层
两个建议:
1. screen的定义部分从脚本的label里剥离出来,放screen.rpy里更合适。
2. 用 show screen 语句显示自定义界面,按钮上绑 Hide 行为。如果要防止鼠标点击穿透,在弹出界面定义中添加一句“modal True”。
回复 支持 1 抱歉 0

使用道具 举报

发表于 2021-4-25 01:04:58 | 显示全部楼层
Call('science')好像是调用label不是screen吧,label science里面才call screen的,所以下面加个return
回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2021-4-25 10:49:39 | 显示全部楼层
Lost 发表于 2021-4-25 01:04
Call('science')好像是调用label不是screen吧,label science里面才call screen的,所以下面加个return ...

大佬你好,按照你的建议我又修改了一下,现在不会继续到label phy1了,但是他跳回的并不是screen2,而是screen2下面的那些文本。如果想要他回到screen2 去重新选择的话,怎么码比较好?下面这段是label science 里的码(部分)
[RenPy] 纯文本查看 复制代码
label science:
    screen science:
        $ quick_menu = False
        add "images/system/science_back.png"
        imagebutton idle "images/system/phy.png" hover "images/system/phy_hover.png" action[Hide("screen2"),Jump("phy1"),SetVariable("phy",phy+1)] focus_mask True
        imagebutton idle "images/system/math.png" hover "images/system/math_hover.png" action[Hide("screen2"),Jump("math1"),SetVariable("math",math+1)] focus_mask True
        imagebutton idle "images/system/com.png" hover "images/system/com_hover.png" action[Hide("screen2"),Jump("com1"),SetVariable("com",com+1)] focus_mask True
        imagebutton idle "images/system/che.png" hover "images/system/che_hover.png" action[Hide("screen2"),Jump("che1"),SetVariable("che",che+1)] focus_mask True
        imagebutton idle "back_navi.png"  action Return() focus_mask True

    call screen science
    return
    label phy1:
        $ randomnumber = renpy.random.randint(1, 100)
        $ phy = phy + randomnumber
        if randomnumber >= 50:
            $ show_quick_menu = True
            "学的不错!"
        elif randomnumber <= 50:
            $ show_quick_menu = True
            "学的是个jb"
        "你现在的物理成绩:[phy]"
    return


screen2的码
[RenPy] 纯文本查看 复制代码
    label home2:
    hyi "下面开始养成界面的测试"
    hyi "假设我们为了高考学习吧w"
    hyi "现在我们的成绩是0"
    hyi "如果学习后的数值大于50,则这次学的还不错,会显示学的不错!"
    call screen screen2
    screen screen2:

        $ quick_menu = False
        add "images/system/sys_back.png"
        imagebutton idle "images/system/sports.png" focus_mask True
        imagebutton idle "images/system/science.png" action[Call("science")] focus_mask True
        imagebutton idle "images/system/rest.png" focus_mask True
        imagebutton idle "images/system/game.png" action [Call("game")] focus_mask True
        imagebutton idle "images/system/liberal_arts.png" action [Call("liberal_arts")] focus_mask True
        imagebutton idle "images/system/outdoor_act.png" action [Call("outdoor_act")] focus_mask True
        imagebutton idle "images/system/club.png" action [Call("club")] focus_mask True
回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2021-4-25 11:33:16 | 显示全部楼层
被诅咒的章鱼 发表于 2021-4-25 08:48
两个建议:
1. screen的定义部分从脚本的label里剥离出来,放screen.rpy里更合适。
2. 用 show screen 语句 ...

我悟了,结合了两位的写法,成功改好了谢谢!
回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2021-4-25 11:36:17 | 显示全部楼层
Fatestaymorning 发表于 2021-4-25 11:33
我悟了,结合了两位的写法,成功改好了谢谢!

我最后的码
第一个进入选择界面的码
[RenPy] 纯文本查看 复制代码
    label home2:
    hyi "下面开始养成界面的测试"
    hyi "假设我们为了高考学习吧w"
    hyi "现在我们的成绩是0"
    hyi "如果学习后的数值大于50,则这次学的还不错,会显示学的不错!"
    show screen screen2


第二个选择界面
[RenPy] 纯文本查看 复制代码
screen screen2:

    zorder 15
    $ quick_menu = False
    add "images/system/sys_back.png"
    imagebutton idle "images/system/sports.png" focus_mask True
    imagebutton idle "images/system/science.png" action[Call("science")] focus_mask True
    imagebutton idle "images/system/rest.png" focus_mask True
    imagebutton idle "images/system/game.png" action [Call("game")] focus_mask True
    imagebutton idle "images/system/liberal_arts.png" action [Call("liberal_arts")] focus_mask True
    imagebutton idle "images/system/outdoor_act.png" action [Call("outdoor_act")] focus_mask True
    imagebutton idle "images/system/club.png" action [Call("club")] focus_mask True

第三个选择界面(部分)
[RenPy] 纯文本查看 复制代码
label science:
    screen science:
        zorder 20
        $ quick_menu = False
        add "images/system/science_back.png"
        imagebutton idle "images/system/phy.png" hover "images/system/phy_hover.png" action[Hide("screen2"),Jump("phy1"),SetVariable("phy",phy+1)] focus_mask True
        imagebutton idle "images/system/math.png" hover "images/system/math_hover.png" action[Hide("screen2"),Jump("math1"),SetVariable("math",math+1)] focus_mask True
        imagebutton idle "images/system/com.png" hover "images/system/com_hover.png" action[Hide("screen2"),Jump("com1"),SetVariable("com",com+1)] focus_mask True
        imagebutton idle "images/system/che.png" hover "images/system/che_hover.png" action[Hide("screen2"),Jump("che1"),SetVariable("che",che+1)] focus_mask True
        imagebutton idle "back_navi.png"  action Return() focus_mask True

    call screen science
    return
    label phy1:
        $ randomnumber = renpy.random.randint(1, 100)
        $ phy = phy + randomnumber
        if randomnumber >= 50:
            $ show_quick_menu = True
            "学的不错!"
        elif randomnumber <= 50:
            $ show_quick_menu = True
            "学的是个jb"
        "你现在的物理成绩:[phy]"
    return

回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2021-4-25 11:38:20 | 显示全部楼层
本帖最后由 Fatestaymorning 于 2021-4-25 13:46 编辑
被诅咒的章鱼 发表于 2021-4-25 08:48
两个建议:
1. screen的定义部分从脚本的label里剥离出来,放screen.rpy里更合适。
2. 用 show screen 语句 ...

懂了,用modal True他就不会点一下继续推进剧情了,谢谢大佬
回复 支持 抱歉

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|RenPy中文空间 ( 苏ICP备17067825号|苏公网安备 32092302000068号 )

GMT+8, 2024-3-28 23:48 , Processed in 0.037155 second(s), 14 queries , File On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表