[Solved] How to affect multiple screens with the same transition?

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
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

[Solved] How to affect multiple screens with the same transition?

#1 Post by yon »

What I'm trying to do is hide/show multiple screens in the same transition.

Between scenes, here is what I'd like to happen
  • hide screen UI with dissolve
  • scene black with fade
  • (some scene transition text is shown)
  • scene (whatever the next scene's BG image is) with fade
  • UI shows with dissolve
Now, this is all fairly seamless as I have it now, with just the one screen. But, I'm trying to show two screens (three later, once I implement it). I'd like all of the UI to hide at the same time, and all of the UI to come back at the same time.

Maybe there's something else entirely I'm meant to be doing right now, but I'm just not understanding this?

Here's what I currently have for my code, where it visually hides an element, THEN the next one, and same for showing:

Code: Select all

            # SCENE TRANSITION --------------------------------- #
            hide screen locbox with dissolve
            hide screen calbox with dissolve
            scene black with fade

            # Some scene transition text here

            # SCENE - change scene variable
            scene enterscenetitle with fade
            show screen locbox with dissolve
            show screen calbox with dissolve
            # -------------------------------------------------- #
locbox - UI to show the location
calbox - UI to show the calendar (date and time)

Is there any way I can get these two to hide or show on the same line?
Last edited by yon on Tue Aug 16, 2022 5:18 pm, edited 1 time in total.

Hakkie
Newbie
Posts: 10
Joined: Sat Dec 02, 2017 7:13 am
Contact:

Re: How to affect multiple screens with the same transition?

#2 Post by Hakkie »

Would this work?

Code: Select all

screen screen_main:
    # screen code here

    use screen_inventory
    use screen_tooltip
    use screen_navbar

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

Re: How to affect multiple screens with the same transition?

#3 Post by Ocelot »

do X with Y is equivalent to

Code: Select all

with None
do X
with Y
So, if you wish same Y applied to multiple X, you need to drop short version and use with command separately.
< < insert Rick Cook quote here > >

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

Re: How to affect multiple screens with the same transition?

#4 Post by Alex »

yon wrote: Sun Aug 14, 2022 6:16 am ...Is there any way I can get these two to hide or show on the same line?
You can create a function to hide/show several screens at once, like

Code: Select all

screen a_scr():
    text "A" align(0.5, 0.1)
    
screen b_scr():
    text "B" align(0.5, 0.15)
    
screen c_scr():
    text "C" align(0.5, 0.2)
    
init python:
    def hide_screens_func(screens_list):
        '''Function takes a list of screens (should be strings,
        in brackets even if it is only one screen).'''
        
        for scr in screens_list:
            renpy.hide_screen(scr)
        renpy.with_statement(Dissolve(1.0))
            
    def show_screens_func(screens_list):
        '''Function takes a list of screens (should be strings,
        in brackets even if it is only one screen).'''
        
        for scr in screens_list:
            renpy.show_screen(scr)
        renpy.with_statement(Dissolve(1.0))


# The game starts here.

label start:
    "..."
    show screen a_scr
    "... ..."
    show screen b_scr
    show screen c_scr
    "... ... ..."
    $ hide_screens_func(['a_scr', 'b_scr', 'c_scr'])
    "!!!"
    $ show_screens_func(['a_scr', 'b_scr', 'c_scr'])
    "?!"
https://www.renpy.org/doc/html/screen_p ... ide_screen
https://www.renpy.org/doc/html/statemen ... _statement

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: How to affect multiple screens with the same transition?

#5 Post by yon »

Hakkie wrote: Sun Aug 14, 2022 8:06 am Would this work?

Code: Select all

screen screen_main:
    # screen code here

    use screen_inventory
    use screen_tooltip
    use screen_navbar
Creating another screen which encapsulates the other two? Maybe, I'm not sure. I haven't thought of that. I'll give the other ideas a try and come back to this if it doesn't pan out.

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

Re: How to affect multiple screens with the same transition?

#6 Post by m_from_space »

yon wrote: Sun Aug 14, 2022 6:16 am Is there any way I can get these two to hide or show on the same line?
@Ocelot already explained this in his riddle like manner:

Code: Select all

hide screen locbox
hide screen calbox
with dissolve

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: How to affect multiple screens with the same transition?

#7 Post by yon »

Ocelot wrote: Sun Aug 14, 2022 9:12 am do X with Y is equivalent to

Code: Select all

with None
do X
with Y
So, if you wish same Y applied to multiple X, you need to drop short version and use with command separately.
Hi again, Ocelot!

I wound up creating subroutines with these functions and calling them whenever I wanted to do my screen transition.

Code: Select all

label hide_screens:
    with None
    hide screen locbox
    hide screen calbox
    with dissolve

    # This should work as a subroutine to hide all screens when the scene transition happens

    return

label show_screens:
    with None
    show screen locbox
    show screen calbox
    with dissolve

    # This should work as a subroutine to show all screens when the scene transition happens

    return
And I call them like so.

Code: Select all

# SCENE TRANSITION --------------------------------- #
call hide_screens
scene black with fade

# scene transition text here

# SCENE - change scene variable
scene black with fade
call show_screens
# -------------------------------------------------- #
Now, both screens hide and show at the same time!

The only issue now is that I'm realizing they go off just after or just before the textbox appears/disappears, though that may be a separate issue, so I'll mark the issue of trying to use one transition to affect multiple screens at once as solved. Thank you.

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: How to affect multiple screens with the same transition?

#8 Post by yon »

Alex wrote: Sun Aug 14, 2022 10:49 am
yon wrote: Sun Aug 14, 2022 6:16 am ...Is there any way I can get these two to hide or show on the same line?
You can create a function to hide/show several screens at once, like

Code: Select all

screen a_scr():
    text "A" align(0.5, 0.1)
    
screen b_scr():
    text "B" align(0.5, 0.15)
    
screen c_scr():
    text "C" align(0.5, 0.2)
    
init python:
    def hide_screens_func(screens_list):
        '''Function takes a list of screens (should be strings,
        in brackets even if it is only one screen).'''
        
        for scr in screens_list:
            renpy.hide_screen(scr)
        renpy.with_statement(Dissolve(1.0))
            
    def show_screens_func(screens_list):
        '''Function takes a list of screens (should be strings,
        in brackets even if it is only one screen).'''
        
        for scr in screens_list:
            renpy.show_screen(scr)
        renpy.with_statement(Dissolve(1.0))


# The game starts here.

label start:
    "..."
    show screen a_scr
    "... ..."
    show screen b_scr
    show screen c_scr
    "... ... ..."
    $ hide_screens_func(['a_scr', 'b_scr', 'c_scr'])
    "!!!"
    $ show_screens_func(['a_scr', 'b_scr', 'c_scr'])
    "?!"
https://www.renpy.org/doc/html/screen_p ... ide_screen
https://www.renpy.org/doc/html/statemen ... _statement
Is this functionally different than calling the labels the way I decided to? Should I do this instead, or are they roughly the same in the end? Either way, thank you for the reply.

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

Re: How to affect multiple screens with the same transition?

#9 Post by Alex »

yon wrote: Sun Aug 14, 2022 1:37 pm Is this functionally different than calling the labels the way I decided to? Should I do this instead, or are they roughly the same in the end? Either way, thank you for the reply.
In Ren'Py you can achieve your goal several ways - just use the one that more convenient for you. In my sample you can pass a list of screen names to the functions, so you can use this functions to show/hide any screens in game. And it just one line...))

Post Reply

Who is online

Users browsing this forum: No registered users