How to display an image on a custom layer in screens

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
hassohappa
Regular
Posts: 33
Joined: Thu Oct 22, 2015 8:51 pm
Tumblr: me-patra
Contact:

How to display an image on a custom layer in screens

#1 Post by hassohappa »

I have custom layers in my game - images on different layers shift different distances to give it a parallax effect.
In most of the game, images with the tag "bg" automatically go on the layer "farBack" because of this:

Code: Select all

$ config.tag_layer = {'bg' : 'farBack'}
In cases where I want to manually show something else, I use

Code: Select all

show differentImage image1  onlayer differentLayer
However, I can't figure out how to do this on screens. In particular, I'd like to add the main menu background to the layer "farBack" like the other bgs.

In screen language, this is all I know how to do.

Code: Select all

add gui.main_menu_background #?? I could show it at a transform, but I don't know how to touch the layer it appears on. Also, as far as I know there's no way to simply show it with an image tag like "bg", like i have in the rest of the game
I'm willing to compromise by displaying the entire screen (not just the main menu bg) on the custom layer, and on other screens this works.

Code: Select all

label call_cool_screen:
    $renpy.call_screen("cool_screen",_layer="farBack") 
But this doesn't work on the main menu...?

Code: Select all

label before_main_menu:
    $renpy.call_screen("main_menu",_layer="farBack") #I've tried putting this, but it had no effect.
Thanks in advance for any advice!! :?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to display an image on a custom layer in screens

#2 Post by PyTom »

While you can't easily do this for the main menu, you could possibly do:

Code: Select all

label main_menu:
    $ renpy.call_screen('main_menu', _later="farBack")
    return
I'm not sure how well this will work, since other screens are hidden and shown using the main menu. You could also get rid of the main menu backgrounds, and add the parallax background in the main_menu layer before showing the screen.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
hassohappa
Regular
Posts: 33
Joined: Thu Oct 22, 2015 8:51 pm
Tumblr: me-patra
Contact:

Re: How to display an image on a custom layer in screens

#3 Post by hassohappa »

Thanks Tom! I've tried this:

Code: Select all

label main_menu:
    $ renpy.call_screen('main_menu', _layer="farBack")
    return
But it still appeared on the default layer. I realized the problem is actually that the effects of my custom layers don't kick in until the start label. I just never noticed this with my other screens because I never called any of them before start. If I move the renpy.call_screen('main_menu', _layer="farBack") to after the Start label, it works! But not before, even if I call a screen from the main menu screen itself. The same is true if I replace the main menu background and add my parallax background to the custom layer -- it will appear on the custom layer if I do this after start, but not before.

In the block where the custom layers are created and have fancy things applied to them, I've tried changing the init priority number to other values like -999, but I couldn't see any difference. It seems that they're just destined to not kick in until the start label.

Code: Select all

init 800 python:
    class MouseParallax(renpy.Displayable): #etc. 
I guess I'll have to live with having a normal non-parallax menu screen. Oh, the humanity...

The only other (terrible) solution I can think of is having the game jump straight to the Start label, immediately call the main menu from there, and then starting a new game on a label Start2.

Post Reply

Who is online

Users browsing this forum: No registered users