Problem with screen action "Hide" (and layers ?)

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
Gigan
Regular
Posts: 28
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Problem with screen action "Hide" (and layers ?)

#1 Post by Gigan »

Hello everyone ! I've had a problem for the past 3 #&@+!! hours and I can't seem to find a solution.

I have a screen full of imagebuttons and hotspots. When I click on those, they jump to a label.
Thing is, I noticed that jumping to a label hides the screens, which makes the game look silly visually when the screens' buttons are part of the background.
So I created another screen, with the same imagebuttons with a "Return()" action and put that screen on a custom layer so it can be behnd the character's sprite when on the label. I know there're better solutions but I'm a newbie with newbie skills.

Problem is, I can't seem to be able to hide that screen anymore ? Imagebutton's action "Hide" doesnt seem to be working, neither does a simple "hide screen" inside a label.

Here's the whole code + some pics :

Code: Select all

init:
    define config.layers = ['blscreen', 'background', 'buttons', 'master', 'transient', 'screens', 'overlay']

### Defined new layers so the buttons are always on screen and unclickable whenever there's some text
### "Background" is for the bg, "buttons" is for the unclickable screens behind the characters
### ...and "Master" is for the sprites. Normal clickable screens are on the "screen" layer.

label pre_mapstart_after_prologue:
    $ renpy.music.play("audio/ost_fissa_outskirts.ogg", "music", if_changed=True)
    scene bg pre_mapstart onlayer background with dissolve
    call screen pre_mapstart_hotspot with fastdissolve

### The "hub" of the scene, where all the clickable areas are
### This label always looks fine
### 

label pre_mapstart_embleme:
    $ renpy.show_screen("pre_mapstart_hotspot_ib", _layer="buttons")
    a "A stylized fairy. The emblem of Perineam."
    hide screen pre_mapstart_hotspot_ib
    call screen pre_mapstart_hotspot
    with fastdissolve

label pre_mapstart_queendom:
    $ renpy.show_screen("pre_mapstart_hotspot_ib", _layer="buttons")
    a "Deep in this dank, dimly lit cave lies the Fairy Queendom."
    hide screen pre_mapstart_hotspot_ib
    call screen pre_mapstart_hotspot
    with fastdissolve

### Labels "pre_mapstart_embleme" and "pre_mapstart_queendom" are the labels for what
### the screen "pre_mapstart_hotspot_ib" has been created. Since screens disappear after jumping to a label,
### and since I didn't want to bother making the buttons of screen "pre_mapstart_hotspot" unclickable and visible
### with a "if/else" statement (I'm not smart enough) I created a new screen containing the same imagebuttons
### with a Return() action, that I've put on top of the label.
### I've put a "hide screen pre_mapstart_hotspot_ib" at the end of the label to make sure screen "pre_mapstart_hotspot_ib"
### and "pre_mapstart_hotspot" would not be visible at the same time. Doesn't seem to do much.

label pre_mapstart_porte:
    show bg door_finished_routes onlayer background with dissolve
    a "This door... I recognize this craft..."
    call screen pre_mapstart_hotspot
    with fastdissolve
    
### This label has another background. That's where I got my screens were not hiding as I wanted

screen pre_mapstart_hotspot():
    imagemap:
        ground "bg/bg_pre_mapstart2.png"
        hotspot (330, 317, 160, 288): #porte
            mouse "loupe_hover"
            action [Hide("pre_mapstart_hotspot_ib"), Jump("pre_mapstart_porte")]
        hotspot (747, 300, 252, 301): #Fairy Queendom
            mouse "loupe_hover"
            clicked Jump("pre_mapstart_queendom")
        hotspot (800, 122, 90, 88): #Emblème
            mouse "loupe_hover"
            clicked Jump("pre_mapstart_embleme")
        hotspot (217, 667, 467, 50): #Vers Mapstart
            mouse "icon_go_hover"
            action [Hide("pre_mapstart_hotspot_ib"), Jump("mapstart")]
    imagebutton:
        focus_mask True
        xpos 650
        ypos 230
        idle "animated_torche"
        action NullAction()
    if garlandmapstart == True:
        imagebutton:
            focus_mask True
            xpos 100
            ypos 230
            idle "imagebuttons/ib_garland.png"
            action Jump("garland_conv")
    elif beatrice_appears_1 == True:
        imagebutton:
            focus_mask True
            xpos 180
            ypos 230
            idle "beavole"
            action Jump("beatrice_1_premapstart")

### The screen containing the imagebuttons and hotspots

screen pre_mapstart_hotspot_ib():
    imagebutton:
        focus_mask True
        xpos 650
        ypos 230
        idle "animated_torche"
        action Return()
    if garlandmapstart == True:
        imagebutton:
            focus_mask True
            xpos 100
            ypos 230
            idle "imagebuttons/ib_garland2.png"
            action Return()
    elif beatrice_appears_1 == True:
        imagebutton:
            focus_mask True
            xpos 180
            ypos 230
            idle "beavole"
            action Return()

### The screen containing the unclickable imagebuttons, visible during dialogue.
### I've colored the dude in purple here, to check which screen was the trouble-maker, as the buttons are visually the same.
Image
Image
Image
Last edited by Gigan on Mon May 06, 2024 7:32 pm, edited 2 times in total.

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Problem with screen action "Hide" (and layers ?)

#2 Post by philat »

Hiding screens also takes a _layer argument. https://www.renpy.org/doc/html/screen_actions.html#Hide

Gigan
Regular
Posts: 28
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Re: Problem with screen action "Hide" (and layers ?)

#3 Post by Gigan »

...aaaaaand it works perfectly now. Sorry for being a dum-dum 8__8
Thanx a lot for your help once again ! o/

Gigan
Regular
Posts: 28
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Re: Problem with screen action "Hide" (and layers ?)

#4 Post by Gigan »

Sorry, screamed victory too fast.
It worked, reloaded my game, and now it does not.

The only way I can get it to work is if I click on the hotspot leading to the labels pre_mapstart_embleme/pre_mapstart_queendom:. If I don't the screen pre_mapstart_hotspot_ib doesn't hide.

Code is the same as above. Only changes are

Code: Select all

screen pre_mapstart_hotspot():
    imagemap:
        ground "bg/bg_pre_mapstart2.png"
        hotspot (330, 317, 160, 288): #porte
            mouse "loupe_hover"
            action [Hide("pre_mapstart_hotspot_ib",_layer="buttons"), Jump("pre_mapstart_porte")]
...

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

Re: Problem with screen action "Hide" (and layers ?)

#5 Post by m_from_space »

Gigan wrote: Mon May 06, 2024 6:29 pm Thing is, I noticed that jumping to a label hides the screens, ...
That is only true if you called the screen in question, instead of just showing it. There is no need to put it on another layer, it makes things more complicated in my opinion. Screens should be shown on the screens layer, not elsewhere.

Gigan
Regular
Posts: 28
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Re: Problem with screen action "Hide" (and layers ?)

#6 Post by Gigan »

That's most probably me being dumb but most of my screens having hotspots/ground images, is there a way to keep them on the screen layer without them hiding the sprites on the master layer ? I started that whole layer thing cause I need my buttons to be behind the characters. :/

(Again, thx for your time.)

giorgi1111
Newbie
Posts: 14
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Problem with screen action "Hide" (and layers ?)

#7 Post by giorgi1111 »

U must devided screen s top screen middle bottom and hide only maybe middle top and bottom leave
Put screens you want allways shown in start label

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot], Ocelot