A button has icons partially hidden behind it. When the button is hovered, the icons spread out and go next to the button, until the button is unhovered, when they will retract and only be partially visible behind the button again.
I figured I would do this with a showif, either showing the expanding/retracting, or the stationary retracted icons. It works, but if I include the marked "else" statement, the "on show" part of the transform "questicons" does never execute. The "on show" from the transform "questiconswait", however, seems to work normally.
If I comment out the "else" part, "questicons" works perfectly.
I'm assuming the other transform somehow disturbs the first transform, but I can't find out how or what I have to do to make it work. What also puzzles me is that the second transform's "on show" does work.
Code: Select all
init python:
class Quest:
def __init__(self, characters, bg, label):
self.icons = []
for c in characters:
self.icons.append(character_icon[c])
self.bg = bg
self.label = label
def execute(self):
renpy.call(self.label)
default character_icon = {'red': slide_red, 'green': slide_green, 'blue': slide_blue}
default myquest = Quest(['red', 'green', 'blue'], 'images/idle_buttonlong.png', 'questlabel')
default hoveredquest = None
define slide_red = Solid('#ff0000', xysize=(50,50))
define slide_green = Solid('#00ff00', xysize=(50,50))
define slide_blue = Solid('#0000ff', xysize=(50,50))
transform questicons(x):
xpos -10*(x+1)
xanchor 0.0
yalign .5
on show:
linear 0.12 xpos -155*(x+1)
on hide:
linear 0.12 xpos -10*(x+1)
transform questiconswait(x):
xanchor 0.0
yalign .5
xpos -10*(x+1)
on show:
alpha 0.0
0.12
alpha 1.0
screen questbutton(quest):
style_prefix "questbutton"
fixed:
xalign 1.0
xfit True
vbox:
fixed:
ysize 65
xfit True
showif hoveredquest == quest:
for n, i in reversed(list(enumerate(reversed(quest.icons)))):
add i at questicons(n)
else: # <--- THIS
for n, i in reversed(list(enumerate(reversed(quest.icons)))):
add i at questiconswait(n)
imagebutton:
idle quest.bg
action Jump(myquest.label)
hovered SetVariable('hoveredquest', quest)
unhovered SetVariable('hoveredquest', None)
label start:
show screen questbutton(myquest)
# more stuff