马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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
|