Ren'Py Renpy image positioning

SecretSal

Active Member
Aug 25, 2016
793
1,841
Hi all,
I was experimenting with converting a Unity game to Renpy.
The image size is less than 1920x1080, so I wanted to make the game in a 1080 window, keeping the image aligned to the top of the screen and the textbox below so that they don't overlap.
Is there a way to make it so that all images get posted using the 'show (image) at top' modifier by default? Would save a heap of time.
Thanks!
 

Epadder

Programmer
Game Developer
Oct 25, 2016
567
1,046
You could use a custom transform like:
Python:
    transform transform_CenterAtTop:
        xalign 0.5
        yalign 0.0
And when you show an image you would do "show imagename at transform_CenterAtTop".

Or you could make a dynamic image that you then composite to make an image that is 1920x1080.

Example composite.
Python:
image dynamicimage_ImageToComposite = "pathtoimage/[imagename].ext"
image dynamicimage_CompositeImage = Composite(
    (1920,1080),
    (0,0), "background.ext",
    (valuetoalignincenter,0), "dynamicimage_ImageToComposite" #replace valuetoalignincenter with result of (1920 - length of the images) / 2, this should be the same for all images otherwise it won't stay centered.
    )
You will have to create a variable for imagename that you replace to show your images and then use a single python command to change the image displayed. Example below:

Python:
default imagename = "Picture"
label somelabelname:
    $ imagename = "01"
    show dynamicimage_CompositeImage
    "TEXT HERE"
    $ imagename = "02"
    "TEXT HERE"
    $ imagename = "03"
    "TEXT HERE"
    $ imagename = "04"
    "TEXT HERE"
If you want to use a different transform or transition on the image when it changes, you have to use the "show" command again.