[SOLVED] Showing a screen behind sprites ?

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:

[SOLVED] Showing a screen behind sprites ?

#1 Post by Gigan »

[EDIT] Changed the title to reflect new problem

Hello everyone ! I have a little problem with my point & click game.

Most of my screens have imagebuttons that, when clicked, jump to a label and trigger some dialogue. Ex :

Code: Select all

screen forest_glade_1():
    imagebutton:
        focus_mask True
        xpos 723
        ypos 344
        idle "imagebuttons/kaeli_card_phoebus_statue.png"
        action Jump("got_kaeli_card")
        
########################################"
        
label got_kaeli_card:
    show fairy
    f "Mmh ? What's this ?"
    call screen forest_glade_1
Problem is, when I jump to said label, my sprites appear but the imagebuttons disappear. Sometimes it doesnt matter, but when they're part of the background, it looks weird.

I kinda fixed it by showing the screen in the first line of the label and by putting another screen with an empty png on top of it to make the buttons unclickable during the dialogue, so like this :

Code: Select all

screen disable_screen_imagebuttons():
    imagebutton:
        idle "disable_buttons.png"
        action Return()
        
label got_kaeli_card:
    show screen forest_glade_1
    show disable_screen_imagebuttons
    show fairy
    f "Mmh ? What's this ?"
    call screen forest_glade_1
...so now the button jump to the label, stay on screen and is unclickable during the dialogue, but the sprite (here, "fairy") doesn't appear.

Anyway idea how to fix it ?

TLDR :
- I want my imagebuttons to stay on screen when clicked on, but they should be unclickable during the dialogue so the player doesnt trigger the dialogue again and again.
- My sprites must stay on screen as well.
Last edited by Gigan on Sat May 04, 2024 7:55 pm, edited 2 times in total.

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

Re: Showing a screen (and images) with unclickable imagebuttons ?

#2 Post by philat »

You can use the sensitive property for this (https://www.renpy.org/doc/html/screens. ... sitive_alt )

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

Re: Showing a screen (and images) with unclickable imagebuttons ?

#3 Post by Gigan »

Thank you for your help ! Button is no longer clickable. (Not sure I coded it the right way but here's how I've done it, for those having the same problem)

Code: Select all

            imagebutton:
                focus_mask True
                xpos 940
                ypos 125
                idle "imagebuttons/ib_mansion_key.png"
                action [SetVariable ("imagebutton_enabled", False), SensitiveIf (imagebutton_enabled), Jump("ruben_mermen_cobalt_key")]
Now for my other problem, I found that the sprites were not disappearing. They were just behind the screen (which had an imagemap/ground).
Is there a way so when I 'show' the screen in the label, it's shown behind the sprites ?

I tried this :

Code: Select all

screen forest_glade_1():
    imagebutton:
        zonder -1
        focus_mask True
        xpos 723
        ypos 344
        idle "imagebuttons/kaeli_card_phoebus_statue.png"
        action [SetVariable ("imagebutton_enabled", False), SensitiveIf (imagebutton_enabled), Jump("got_kaeli_card")]
        
########################################"
        
label got_kaeli_card:
    show screen forest_glade_1
    show fairy zonder 1
    f "Mmh ? What's this ?"
    call screen forest_glade_1
...but it doesnt seem to be working, as the screen still is above the sprite (and I can't see myself adding "zonder 1" to all my sprites anyway)

...so I tried a custom layer but weirdly, it doesn't seem to work either ?

Code: Select all

define config.layers = ['background', 'buttons', 'master', 'transient', 'screens', 'overlay']
I would put my background image on layer 'background', the screen with unclickable imagebuttons on 'buttons' and the sprites would be left on 'master'

Code: Select all

screen forest_glade_1():
    imagebutton:
        focus_mask True
        xpos 723
        ypos 344
        idle "imagebuttons/kaeli_card_phoebus_statue.png"
        action [SetVariable ("imagebutton_enabled", False), SensitiveIf (imagebutton_enabled), Jump("got_kaeli_card")]
        
########################################"
        
label got_kaeli_card:
    scene bg_image onlayer background 
    show screen forest_glade_1(_layer="buttons")
    show fairy
    f "Mmh ? What's this ?"
    call screen forest_glade_1
...but now
- I have a black background, my sprites and no imagebuttons
- When I click on an hotspot, the text loops, as if the hotspot was not inactive like the imagebuttons (hotspots needs another action than sensitive ?)

Sorry to bothering again. I swear I tried to fix it myself for 4 fucking hours... 8__8

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

Re: Showing a screen behind sprites ?

#4 Post by philat »

Well, I don't have your images and don't know what you're seeing, so keep in mind that this is difficult to answer, but:

- check whether there isn't any default background being shown (clear the master layer with an empty scene statement)

- the syntax is either show screen forest_glade_1 onlayer buttons or $ renpy.show_screen("forest_glade_1", _layer="buttons") - yes, figuring out whether you should put something in quotes or not is a PITA ;)

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

Re: Showing a screen behind sprites ?

#5 Post by Gigan »

Thx again for your help ! I cleared the master layer and now everything works fine. I'll probably have to rewrite most of my code to include the new layers but heh. It works ! ;)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]