Custom screen Change background

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
kully00000
Newbie
Posts: 7
Joined: Fri Jun 08, 2018 9:00 pm
Deviantart: kelly00000
Contact:

Custom screen Change background

#1 Post by kully00000 »

I have been learning how to use Ren'Py for about half a week now and have ran into some trouble regarding changing the background of my custom screens...

I am only able to change the background of the main menu and the game menu but not any of the other screens (for example the about, preferences, save/load, history... as well as my own)
More specifically, I have a character screen in my game which will display all of the names of the characters the PC has met. The only thing I am stuck on is changing the background.XD

Could someone PLEASE explain to me how I could change backgrounds of the other screens as well as my own?
Thank you,

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Custom screen Change background

#2 Post by kivik »

To directly change the background of a screen, you need to look at the screen code for that specific screen.

To figure out what you need to do in the future, check out this page first: https://www.renpy.org/doc/html/style_properties.html

Under each heading you'll find different type of style properties you can change, and we can find background under Window Style Properties: https://www.renpy.org/doc/html/style_pr ... properties

As it states, you can use window style properties on windows, frames and buttons, so those are the elements of your screen that you want to change. In this case it's most likely the highest level window of your menu screens.

With background you can specify an image, a colour, a Frame() (stretches with your element) or None.

To apply it you look at your screen code, for example if you're changing the window, you can either put it after the element on the same line, or embed it underneath as a block. Since window and frames are typically blocks already, you may as well put them underneath within the block:

Code: Select all

window:
    background "images/my_custom_background.png"
    # what goes inside your window.
Hope this helps, come back if you need more help on it :)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Custom screen Change background

#3 Post by xavimat »

I'd suggest a more simple approach.
Don't call it "background" call it "how can I add an image in a screen?”. Use "add" to put an image. If the image is the first thing you put in the screen and it fits the entire screen, it does the same function as the background and you don't need to use "window" or styles.

Code: Select all

 screen test ():
     add "my_background.jpg"
     vbox:
         # more stuff
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

kully00000
Newbie
Posts: 7
Joined: Fri Jun 08, 2018 9:00 pm
Deviantart: kelly00000
Contact:

Re: Custom screen Change background

#4 Post by kully00000 »

Thank you both of you that worked! :D

Have a good day

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, Google [Bot]