How to renpy.pause() and not hide the previous 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
newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

How to renpy.pause() and not hide the previous screen?

#1 Post by newbiemate »

Here is a test case:

Code: Select all

init -1:
    # ATLS
    
    transform tf_throw_ball():
        subpixel True
        xpos 960
        ypos 1080
        rotate -360
        linear 0.5 xpos 0 ypos 0 rotate 720


    
screen doit():

                    
    imagebutton:
        action Return("light1")
        idle images['light_off']
        xpos 400
        ypos 0
        
    imagebutton:
        action Return("light1")
        idle images['light_off']
        xpos 800
        ypos 0 
    
    imagebutton:
        action Return("light1")
        idle images['light_off']
        xpos 1200
        ypos 0
        
    text "%s" % outcome xpos 100 ypos 100 color '#000'
        
screen render_ball():
    
    add images['ball'] at tf_throw_ball()
       
label start():

    scene bg background
    default outcome = 0
    
    while True:  
    
        call screen doit()
        $ res = _return
        
        if res:

                show screen render_ball()
                $ renpy.pause(0.5)
                $ outcome += 5
                hide screen render_ball
    
    return
When I click on any imagebutton (the 'lights'), the ball animation renders using ATL, and then I do a pause for 0.5 seconds so that the animation can run. After the animation, I update a variable and then hide the ball animation.

However, when renpy pauses to allow for the animation to run, all of the lights in the doit() screen disappear, and I only see the ball move across the screen. When the ball gets hidden, the lights show up again.

Is there something wrong with the code? Why does the ball animation not show with the lights at the same time?

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: How to renpy.pause() and not hide the previous screen?

#2 Post by rames44 »

You’re “calling” the doit screen. When you execute the Return from that screen, the screen is hidden automatically. So the way your code is written, you put the doit screen up until a button is pressed, the it’s hidden, the render_ball screen is shown, you pause, then hide the render_ball screen and show the doit screen again via the “call.”

If you’re trying to make some kind of minigame, you might want to code that all inside the screen, using actions in the doit screen to show the render_ball screen. Then only Return from the doit screen when the game is over and it’s time to continue with the subsequent dialog.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]