Page 1 of 1

Making fading popups in a screen [SOLVED]

Posted: Sat Apr 13, 2024 10:20 am
by kedta35
I want to make popups that quickly show up and disappear, notifying you that you cant do certain actions.

I've tried doing it like below but the python part doesn't change popup_cant to false.

Code: Select all

transform popup_out:
    alpha 1.0
    linear 0.5 alpha 0

Code: Select all

    if popup_cant_go == True:
        add get_popup_cant_go() at popup_out

    imagebutton:
        auto "images/button1_%s.png"
        at button1
        action SetVariable("popup_cant_go", True)

Code: Select all

    def get_popup_cant_go():

        return "cant go popup.png"
        renpy.pause(0.5)
        popup_cant_go = False

Re: Making fading popups in a screen

Posted: Sat Apr 13, 2024 1:19 pm
by m_from_space
kedta35 wrote: Sat Apr 13, 2024 10:20 am I want to make popups that quickly show up and disappear, notifying you that you cant do certain actions.
Renpy has an internal notification feature you can use.

Code: Select all

screen myscreen():
    textbutton "Click me!" action Notify("You clicked me.")
    
# you can also use it as a python function in labels etc.:
label start:
    "Let's notify the user..."
    $ renpy.notify("Don't forget to save your game once in a while!")
    return

Re: Making fading popups in a screen

Posted: Sat Apr 13, 2024 3:11 pm
by kedta35
I was thinking more of like a custom image popping up on top of the button you press instead

Re: Making fading popups in a screen

Posted: Sat Apr 13, 2024 4:09 pm
by Ocelot
1) Nothing after return is executed.
2) Even if would, your use of renpy.pause is likely to cause interaction withing interaction error
3) popup_cant_go = False creates a local variable which is instantly destroyed in this case. It odes not modyfy anything.

Your best bet is to show a custom screen with a timer which hides it. SOmeting loke:

Code: Select all

transform popup_display:
    on "show":
        alpha 0.0
        linear 1.0 alpha 1.0
    on "hide":
        alpha 1.0
        linear 1.0 lapha 0.0

screen popup(location):
    add "cant_do_that" at popup_display:
        anchor 0.5, 0.5
        pos location
    timer 1.0 action Hide()


# . . .
    imagebutton:
        auto "images/button1_%s.png"
        at button1
        action Show("popup", location=(0.5, 0.5))

Re: Making fading popups in a screen

Posted: Sat Apr 13, 2024 8:07 pm
by kedta35
That works perfectly for what I want, Thank you.