找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 22|回复: 1

[求助] 为什么add不能用于展示SpriteManager呢?

[复制链接]
发表于 17 小时前 | 显示全部楼层 |阅读模式

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

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

×
rt, 下面是所有的代码.
遇到的问题是, 用label里用show expression button_sm 是可以正常显示button_sm这个SpriteManager的.
但是我希望的是在screen里面, 在按下按钮以后对应的位置显示这个SpriteManager.
不知道是不是add 不能用于SpriteManager这种可视化组件.

[RenPy] 纯文本查看 复制代码
init python:
    import random
    import math
    
    button_sm = None
    button_sp = []

    def update_bubbles(st):

        for i in store.button_sp:
            
            assigned_zoom = 0.1 + st*0.1
            assigned_alpha = 1.0 - st*0.5

            if assigned_alpha < 0:
                assigned_alpha = 0

            i.set_child(Transform("bubble.png",alpha=assigned_alpha,zoom=assigned_zoom))

            if i.x > 960:
                i.x += int(renpy.random.randint(0,10) * st)
            else:
                i.x += int(renpy.random.randint(-10,0) * st)

            if i.y > 540:
                i.y += int(renpy.random.randint(0,10) * st)
            else:
                i.y += int(renpy.random.randint(-10,0) * st)
    
        return 0.01  # 下次更新间隔(秒)

    def create_sm():

        store.button_sm = SpriteManager(update=update_bubbles)

        store.button_sp = []

        for i in range(25):
            bubble = Transform("bubble.png",zoom=0.1)

            store.button_sp.append(store.button_sm.create(bubble))
        
        for i in store.button_sp:
            i.x = 960 + renpy.random.randint(-50,50)
            i.y = 540 + renpy.random.randint(-10,10)

screen bubble_button():
    predict False
    default show_sm = False

    # 按钮(放在屏幕下方中央)
    textbutton "✨ 点我冒泡泡":
        xalign 0.5
        yalign 0.5
        text_align (0.5,0.5)
        action SetScreenVariable("show_sm",True), Notify("泡泡已出现"), Function(create_sm)
        background Solid("#4CAF50", xsize=200, ysize=60)
        text_color "#fff"
        text_size 24
        hover_background Solid("#66BB6A", xsize=200, ysize=60)

    if show_sm and button_sm is None:
        $ renpy.notify("函数被调用了!")
        $ create_sm()

    if show_sm:
        use button_sm_screen

screen button_sm_screen():
    add store.button_sm

label start:
    show screen bubble_button
    "点击屏幕上方的按钮,看看泡泡特效!"
    "1"
    show expression button_sm
    "3"

    "2"
    hide screen bubble_button
    hide expression button_sm

    return



 楼主| 发表于 17 小时前 | 显示全部楼层
Ren'Py 8.5的粒子不显示bug及规避方案
https://www.renpy.cn/forum.php?mod=viewthread&tid=1848
(出处: RenPy中文空间)
章鱼大佬写了解决办法了
回复 支持 抱歉

使用道具 举报

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

本版积分规则

小黑屋|手机版|RenPy中文空间 ( 苏ICP备17067825号 )

GMT+8, 2026-9-7 17:57 , Processed in 0.030669 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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