Adding delay between displayables in a 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
RVNSN
Regular
Posts: 36
Joined: Mon Apr 08, 2019 3:54 pm
Projects: Lust & Piracy
itch: rvnsn
Contact:

Adding delay between displayables in a screen

#1 Post by RVNSN »

How do you make a delay between displayables in a screen? I'm attempting to add an animation (ships_log_opening_anim_1) for my stats screen - it's a book opening - and delay any screen actions that come after it. As it is, the text buttons that come after load at the same time (obviously).

Code: Select all

screen statpage():


    fixed:
        imagebutton auto "gui/clear_overlay_%s.png":
            xalign 0.5
            yalign 0.5
            action NullAction()

        add "ships_log_opening_anim_1" #(delay = 5)

#        imagebutton auto "gui/ships_log_inside_%s.png":
#            xalign 0.5
#            yalign 0.5
#            action NullAction()
#        textbutton _("[name]") text_color "#000000" text_hover_color "#980002" xpos 550 ypos 150 action ui.callsinnewcontext ("call_panstat")



    vbox:
        textbutton "[name]":
            text_color "#000000"
            text_hover_color "#980002"
            xpos 550 ypos 150
            action ui.callsinnewcontext ("call_panstat")

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Re: Adding delay between displayables in a screen

#2 Post by nananame »

While you could use a timer I don't recommend that as it seems timer's are quite intensive.

Why not split the two? either have it on two screens, so on one screen you have the animation and then the other has buttons and you call it like:
show screen animation
pause 5#duration of animation
hide screen animation #this is so that if a player clicks he can skip the animation
call screen mainthingy

Or you can even avoid the screen for the animation and simply use an image but the same method as above:
show ships_log_opening_anim_1
pause 5
hide ships_log_opening_anim_1
call screen mainthingy

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

Re: Adding delay between displayables in a screen

#3 Post by Alex »

You could make a variable to check if buttons should be shown or not, and a timer that will set the proper value to this variable.

Try

Code: Select all

screen test_scr():
    default flag_var = False # default value of screen variable

    add 'ships_log_opening_anim_1' # show your animation

    if not flag_var:
        timer 5.0 action SetScreenVariable("flag_var", True) repeat False

    else: # show some buttons
        vbox:
            textbutton "Test!" action NullAction()

https://www.renpy.org/doc/html/screens.html#timer
https://www.renpy.org/doc/html/screen_a ... enVariable

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Adding delay between displayables in a screen

#4 Post by Remix »

... or put the button vbox at a transform that waits 5.0 seconds before dissolving them in

Code: Select all

transform vbox_show:
    alpha 0.0
    on show:
        pause 5.0
        linear 1.0 alpha 1.0
        
# screen ....
    
    vbox at vbox_show:
        # the buttons
Frameworks & Scriptlets:

User avatar
RVNSN
Regular
Posts: 36
Joined: Mon Apr 08, 2019 3:54 pm
Projects: Lust & Piracy
itch: rvnsn
Contact:

Re: Adding delay between displayables in a screen

#5 Post by RVNSN »

Alex wrote: Thu Jul 02, 2020 1:21 pm You could make a variable to check if buttons should be shown or not, and a timer that will set the proper value to this variable.

Try

Code: Select all

screen test_scr():
    default flag_var = False # default value of screen variable

    add 'ships_log_opening_anim_1' # show your animation

    if not flag_var:
        timer 5.0 action SetScreenVariable("flag_var", True) repeat False

    else: # show some buttons
        vbox:
            textbutton "Test!" action NullAction()

https://www.renpy.org/doc/html/screens.html#timer
https://www.renpy.org/doc/html/screen_a ... enVariable

Thank you all. So far I've only tried Alex's approach, and it works great with one exception. The close button does not delay. Originally the close button had its own screen, but to try to make it delay with the other buttons I added it to the same screen. I'm including some screenshots and a larger section of code so I hopefully don't miss what's making this happen.

...

Edit: I forgot about the hud screen(s) I had made to call in these screens after adding open world gameplay. Removed the line to call close hud screen and that fixed it.

User avatar
RVNSN
Regular
Posts: 36
Joined: Mon Apr 08, 2019 3:54 pm
Projects: Lust & Piracy
itch: rvnsn
Contact:

Re: Adding delay between displayables in a screen

#6 Post by RVNSN »

nananame wrote: Thu Jul 02, 2020 2:20 am While you could use a timer I don't recommend that as it seems timer's are quite intensive.

Why not split the two? either have it on two screens, so on one screen you have the animation and then the other has buttons and you call it like:
show screen animation
pause 5#duration of animation
hide screen animation #this is so that if a player clicks he can skip the animation
call screen mainthingy

Or you can even avoid the screen for the animation and simply use an image but the same method as above:
show ships_log_opening_anim_1
pause 5
hide ships_log_opening_anim_1
call screen mainthingy
nananame, what would the code be like for that?

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Re: Adding delay between displayables in a screen

#7 Post by nananame »

Exactly what I wrote? :D

So, if you want to have it on two screens then when a button is clicked to open the stats screen you go to label open_stat_screen:

Code: Select all

label open_stat_screen:
	show screen animation
	pause 5#duration of animation
	hide screen animation
	call screen statpage

Code: Select all

screen animation():
	add "ships_log_opening_anim_1"

Code: Select all

screen statpage():
    fixed:
        imagebutton auto "gui/clear_overlay_%s.png":
            xalign 0.5
            yalign 0.5
            action NullAction()

    vbox:
        textbutton "[name]":
            text_color "#000000"
            text_hover_color "#980002"
            xpos 550 ypos 150
            action ui.callsinnewcontext ("call_panstat")

So what happens here? Basically when you want to open the stat screen you go to the label. The label first shows the screen which has nothing but the animation and pauses for the duration of the animation. Once the animation is done (or the player clicks to interrupt it - you can put a hard pause too, but I suggest letting players skip it) the screen with the animation is hidden and the stat screen is called. This works fine but there's no real reason to have one screen just for the animation. So you can do the animation without a screen:

Code: Select all

label open_stat_screen:
	show ships_log_opening_anim_1 ###this is the animation you define with atl
	pause 5
	hide ships_log_opening_anim_1
	call screen statpage

User avatar
RVNSN
Regular
Posts: 36
Joined: Mon Apr 08, 2019 3:54 pm
Projects: Lust & Piracy
itch: rvnsn
Contact:

Re: Adding delay between displayables in a screen

#8 Post by RVNSN »

nananame wrote: Tue Jul 07, 2020 3:42 am Exactly what I wrote? :D

So, if you want to have it on two screens then when a button is clicked to open the stats screen you go to label open_stat_screen:
:D right on, thank you. i was trying to figure out how the parts that go under label worked in a screen.

User avatar
RVNSN
Regular
Posts: 36
Joined: Mon Apr 08, 2019 3:54 pm
Projects: Lust & Piracy
itch: rvnsn
Contact:

Re: Adding delay between displayables in a screen

#9 Post by RVNSN »

nananame wrote: Tue Jul 07, 2020 3:42 am Exactly what I wrote? :D

So, if you want to have it on two screens then when a button is clicked to open the stats screen you go to label open_stat_screen:
If I use jump to label in the stats screen the navigation screens (maybe even dialogue box) disappear and I end stuck on that screen without being able to do anything when I close the book.

And is there a way to include Alex's solution as one of the actions for a button? I'm trying to show one animation when flipping forward and another flipping backward upon return without having to duplicate the screens involved.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]