Page 1 of 1
Unable to click Imagebutton while additional screen dissolves
Posted: Fri Dec 20, 2019 2:54 pm
by Rock A Role Games
I am creating a screen with a countdown timer. The timer text blinks in and out, which I have achieved by putting it on a separate screen from everything else that dissolves in and out of existence.
However, while the screen is dissolving, I can't click the imagebuttons of the base screen, even though they are not covered by the additional screen. Is there some way to work around this?
The relevant code:
Code: Select all
screen clicktest:
imagebutton:
idle "testbutton_idle.png"
hover "testbutton_hover.png"
action SetVariable("testvar", 1)
$ n = countertime
for i in range(1,countertime+1):
timer i-0.99 action Show("blinkscreen",transition=Dissolve(0.25),number=n)
$ n -= 1
timer countertime+0.01 action Return()
screen blinkscreen(number):
text "[number]" align (0.5,0.3) size 100
timer 0.25 action Hide("blinkscreen",transition=Dissolve(0.25))
Re: Unable to click Imagebutton while additional screen dissolves
Posted: Fri Dec 20, 2019 6:20 pm
by Alex
If you need blinking text, then try it like
Code: Select all
transform blink:
alpha 0.0
linear 0.5 alpha 1.0
linear 0.5 alpha 0.0
repeat
screen test_scr():
text "Test!" align (0.5, 0.1) at blink
label start:
show screen test_scr
"?!"
https://www.renpy.org/doc/html/atl.html
Re: Unable to click Imagebutton while additional screen dissolves
Posted: Sat Dec 21, 2019 2:11 pm
by Rock A Role Games
Alex wrote: ↑Fri Dec 20, 2019 6:20 pm
If you need blinking text, then try it like
Code: Select all
transform blink:
alpha 0.0
linear 0.5 alpha 1.0
linear 0.5 alpha 0.0
repeat
screen test_scr():
text "Test!" align (0.5, 0.1) at blink
label start:
show screen test_scr
"?!"
https://www.renpy.org/doc/html/atl.html
Thanks for the reply, but this code doesn't quite achieve what I'm after. It allows me to make a given text element blink, but it doesn't work all that well when trying to update the text during the countdown. I tried combining it with a modified version of the countdown code proposed by tuna_sushi
here, but I didn't manage to quite sync the blinking transform and the countdown code.
One alternative I've tried to work on is to use individual text displayables with your suggested transform for each number in the countdown, but I don't know how to get them to appear after a certain amount of time has passed (they would all have to appear with one second intervals). I've tried to use a timer with a custom function, but then nothing happens (probably because I don't actually know exactly how to construct this specific function):
Code: Select all
init python:
def countertext(num):
ui.text("%.0f" % num)
screen clicktest():
$ n = countertime
for i in range(1,countertime+1):
timer i-0.99 action Function(countertext,n)
$ n -= 1
I think the best thing would be if there was some way to override a dissolving screen making buttons unclickable, but I don't know if that's possible.
Re: Unable to click Imagebutton while additional screen dissolves
Posted: Sat Dec 21, 2019 4:46 pm
by Alex
Mmm, what's the problem with syncronizing the blinking with the countdown? The transform takes exactly 1 second, so it should be perfectly sync with timer...
Try this code, is it what you need or?
Code: Select all
default my_time = 5.0
init python:
def my_func(st, at):
global my_time
remaining = my_time - st
if remaining > 2.0:
return Text("%.1f" % remaining, color="#fff", size=72), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=72), .1
else:
return Text("0.0", color="#f00", size=72), None
image countdown = DynamicDisplayable(my_func)
transform blink:
alpha 0.2
linear 0.5 alpha 1.0
linear 0.5 alpha 0.2
repeat
screen test_scr():
add "countdown" align (0.5, 0.1) at blink
# The game starts here.
label start:
"..."
show screen test_scr
"... ..."
hide screen test_scr
"~~~"
$ my_time = 7.0
show screen test_scr
"?!"