I need help defining custom layers[Solved!]

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
DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

I need help defining custom layers[Solved!]

#1 Post by DannX »

Hello, I've been testing Ren'Py and I've find it quite good so far, but I have a question.

Reading through the documentation I've found that Renpy uses layers to display different things on screen, and of them the master layer is used to show both backgrounds and character sprites. I was wondering if it would be possible to split this into two different layers, a 'bg' layer and a 'character' layer for instance, and to define more custom layers. Since it says 'master' layer is used internally, I don't really want to erase it, just set my game so scene statement shows backgrounds in one layer and show statement uses a different but closer to the player.

I'd appreciate if someone experienced in Renpy can offer a suggestion on how to do so or point out, I have some experience with python so I can more or less understand any code and if not I can research.
Last edited by DannX on Mon Mar 12, 2018 3:16 pm, edited 1 time in total.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: I need help defining custom layers

#2 Post by Milkymalk »

https://www.renpy.org/doc/html/displayi ... html#layer

I think you will find links to all your documentation needs there :) Yes, you can define custom layers, just add them to config.layers:
https://www.renpy.org/doc/html/config.h ... fig.layers

When you use the show statement (and I THINK by extension, the scene statement), you can use the onlayer property to tell which layer it should appear on. I don't think you can easily change the default layer, but it would be sufficient to make another layer for BGs and use the master layer for sprites. The new background layer would have to be first in the list config.layers.

EDIT:
https://www.renpy.org/doc/html/config.h ... .tag_layer
With this, you can map a certain image tag to be shown on a specific layer, so you can send all background images to this layer (untested):

Code: Select all

init:
    define config.layers = [ 'background', 'master', 'transient', 'screens', 'overlay' ]
    $ config.tag_layer['bg'] = 'background'
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

Re: I need help defining custom layers

#3 Post by DannX »

OMG thank you!!! That last init code snippet was exactly what I needed, I did read the documentation but I was unsure where or how to actually create and define the variables, that helped a lot really thank you. :D :D

Post Reply

Who is online

Users browsing this forum: No registered users