Making fading popups in a screen [SOLVED]

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
kedta35
Regular
Posts: 45
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

Making fading popups in a screen [SOLVED]

#1 Post 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
Last edited by kedta35 on Sat Apr 13, 2024 8:07 pm, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Making fading popups in a screen

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

kedta35
Regular
Posts: 45
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

Re: Making fading popups in a screen

#3 Post by kedta35 »

I was thinking more of like a custom image popping up on top of the button you press instead

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2410
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Making fading popups in a screen

#4 Post 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))
< < insert Rick Cook quote here > >

kedta35
Regular
Posts: 45
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

Re: Making fading popups in a screen

#5 Post by kedta35 »

That works perfectly for what I want, Thank you.

Post Reply

Who is online

Users browsing this forum: Google [Bot]