Adding a pause to the choice screen?

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
User avatar
dragondatingsim
Regular
Posts: 115
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Adding a pause to the choice screen?

#1 Post by dragondatingsim »

Our choice screen plays a 0.5 second animation (for fading out the image) when clicking a choice. The downside of this is the game continues underneath while this animation is playing.

Previously, I added pause 0.5 statements under every menu choice so the animation does not overlap with what happens next.

Is there perhaps a way to automate this, or change the choice screen in some way to do this automatically?

I'm not very familiar with screen language, so I'm not sure how I would best implement this.

Maybe one potential way to do this would be to call a function that adds a 0.5 second pause before returning, but I'm not sure how that would look like in practice and how I would make this work with the choice screen.

If I implement this now, I would also have to be able to switch between two versions of the choice screen, but I imagine I can do this with a simple variable as described in this thread: viewtopic.php?t=20366

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

Re: Adding a pause to the choice screen?

#2 Post by m_from_space »

dragondatingsim wrote: Tue Apr 09, 2024 9:06 am Is there perhaps a way to automate this, or change the choice screen in some way to do this automatically?
I came up with a solution. Assuming we have a 2 second fadeout delay (just to see that it works):

Code: Select all

# create a fade effect with the showif keyword
transform choice_fade:
    alpha 0.0
    on appear:
        linear 2.0 alpha 1.0
    on show:
        linear 2.0 alpha 1.0
    on hide:
        linear 2.0 alpha 0.0

screen choice(items):
    style_prefix "choice"
    # save the chosen item inside this screen variable
    default chosen_item = None
    vbox:
        for i in items:
            # make sure to only show this if the player didn't already click an option
            showif chosen_item is None:
                # when the player clicks, we save the choice (object), but don't execute it
                textbutton i.caption action SetScreenVariable("chosen_item", i) at choice_fade
    # let a timer actually execute the choice after some delay
    if chosen_item:
        timer 2.0 action chosen_item.action

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Ocelot