Unable to click Imagebutton while additional screen dissolves

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Rock A Role Games
Newbie
Posts: 10
Joined: Sat Sep 07, 2019 1:01 pm
itch: rock-a-role-games
Contact:

Unable to click Imagebutton while additional screen dissolves

#1 Post 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))

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Unable to click Imagebutton while additional screen dissolves

#2 Post 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

Rock A Role Games
Newbie
Posts: 10
Joined: Sat Sep 07, 2019 1:01 pm
itch: rock-a-role-games
Contact:

Re: Unable to click Imagebutton while additional screen dissolves

#3 Post 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.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Unable to click Imagebutton while additional screen dissolves

#4 Post 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
    "?!"

Post Reply

Who is online

Users browsing this forum: FAST WebCrawler [Crawler]