Scene command is incorrectly showing other scenes

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: 76
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Scene command is incorrectly showing other scenes

#1 Post by newbiemate » Thu Aug 22, 2019 6:52 pm

I have a weird issue. I have set up a game where I set the background image using a simple add statement through a screen.

However, it calls other labels which uses the scene statement to setup the background image.

The game interaction loops around, so the backgrounds should be hidden/shown based on what label it's in. This works perfectly for the very first iteration, but all subsequent iterations will show the last scene first, and then immediately the next correct scene, if that makes sense.

Here is a simple demo of the issue:

Code: Select all

screen main():
    add "images/bg black.jpg"

label one():
    scene bg blue with fade
    "showing blue"
    return
 
label two():
    scene bg orange with fade
    "showing orange"
    return

label start:

    show screen main
        
    $ x = 0
    while x < 5:
    
        "showing black"
        
        hide screen main
        call one()
        call two()
        show screen main
        
        $ x += 1
    
    return
Here I have code that will loop the interaction 5 times. This is the order in which I see things:

1st iteration:
- Black background shows
- "showing black" displays
- Blue background shows
- "showing blue" displays
- Orange background shows
- "showing orange" displays

^^ Expected order of background image transitions.

2nd iteration:
- Black background shows
- "showing black" displays
- Orange background flashes briefly
- Blue background shows
- "showing blue" displays
- Orange background shows
- "showing orange" displays

^^ Incorrect order of background images... orange flashes briefly before transitioning into the blue.


And then it keeps repeating the 2nd iteration, where the orange flashes briefly, until the loop dies

Why is the orange showing up in between the black and blue scene transitions? Is there a way to fix this while keeping the way I am displaying my background images (ie, keeping "add" as the main and using "scene" in the label calls)?

User avatar
IrinaLazareva
Veteran
Posts: 364
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: IKG
Location: St.Petersburg, Russia
Contact:

Re: Scene command is incorrectly showing other scenes

#2 Post by IrinaLazareva » Fri Aug 23, 2019 1:15 pm

Showing of the screen main() does not remove the last image (bg orange). The screen just overlaps it.
For a better understanding of the problem, you can temporarily use a small image (for example, 200x200) instead of 'images/bg black.jpg' file...

Anyway, a possible solving is:

Code: Select all

label two():
    scene bg orange with fade
    "showing orange"
    hide bg orange with fade         # <<<<<   add this line
    return
There is a light at the end of the tunnel, just pray it's not a train.
___
TODO: unresolved/нерешённое

newbiemate
Regular
Posts: 76
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: Scene command is incorrectly showing other scenes

#3 Post by newbiemate » Fri Aug 23, 2019 7:24 pm

Thanks, that's a nice idea, but now instead of showing the orange it shows a transparent background briefly and then proceeds to the next scene background.

User avatar
IrinaLazareva
Veteran
Posts: 364
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: IKG
Location: St.Petersburg, Russia
Contact:

Re: Scene command is incorrectly showing other scenes

#4 Post by IrinaLazareva » Sat Aug 24, 2019 4:13 pm

The transparent background will be black after the game is released. But if it is crucial, you can use this instead of «hide bg orange»:

Code: Select all

    scene black with fade
There is a light at the end of the tunnel, just pray it's not a train.
___
TODO: unresolved/нерешённое

User avatar
namastaii
Eileen-Class Veteran
Posts: 1299
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life, Coffea Beans
Github: namastaii
Skype: Discord: lunalucid#7684
Soundcloud: deadseed
itch: lunalucid
Location: USA
Contact:

Re: Scene command is incorrectly showing other scenes

#5 Post by namastaii » Sat Aug 24, 2019 5:23 pm

I don't fully understand the intent of this. I might be able to help if I do. Are you trying to show background images based on the time of day? Based on a variable? Are you trying to animate the backgrounds changing at once?

newbiemate
Regular
Posts: 76
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: Scene command is incorrectly showing other scenes

#6 Post by newbiemate » Thu Aug 29, 2019 5:29 pm

namastaii wrote:
Sat Aug 24, 2019 5:23 pm
I don't fully understand the intent of this. I might be able to help if I do. Are you trying to show background images based on the time of day? Based on a variable? Are you trying to animate the backgrounds changing at once?
I'm not doing anything fancy like that. I have a main scene where the players can see and visit places. When the player clicks on one of these places, it kicks off a new scene, and after that scene is done, I return back to the main. The player can continually visit these scenes from the main, if they want.

Kinda like in my example above, I show my background image using "add" for the main scene. From there, the player interacts with two new scenes (call one() and call two()) before returning back to the main.

The game code is a bit more complicated than this, but I think the example above streamlines the issue I see.

Although do you think this is a bad way of coding this interaction? If so, I could definitely use an example on how to improve it.

newbiemate
Regular
Posts: 76
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: Scene command is incorrectly showing other scenes

#7 Post by newbiemate » Thu Aug 29, 2019 5:30 pm

IrinaLazareva wrote:
Sat Aug 24, 2019 4:13 pm
The transparent background will be black after the game is released. But if it is crucial, you can use this instead of «hide bg orange»:

Code: Select all

    scene black with fade
Thanks, that seems to have worked!

Post Reply

Who is online

Users browsing this forum: No registered users