Renpy Transparency Slider?

swimsoot

Member
Game Developer
Mar 14, 2020
314
714
Hey geniuses,
Anyone know how to code a simple opacity slider in a renpy screen? The idea would be to let the user play with a character's clothes... make them more and less transparent. Can be a single image with a clothing overlay. Nothing fancy.
Thanks!
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,234
Hey geniuses,
Anyone know how to code a simple opacity slider in a renpy screen? The idea would be to let the user play with a character's clothes... make them more and less transparent. Can be a single image with a clothing overlay. Nothing fancy.

Well for the screen it's easy, it's a screen statement:
Python:
screen whatever():

    bar:
        value persistent.transparency
        range 100
Then normally it should works if you define the image in two times.

Firstly the piece of clothes that have to have their transparency directly linked to the slider's value. For this you need to rely on the (ATL), and more precisely on its property.
Python:
image girl1_dress1:
    "girl1/clothes/dress1.png"
    matrixcolor OpacityMatrix( persistent.transparency )
/!\ WARNING /!\
You need Ren'Py version 7.4.6 or higher for this to works, and you need to enable the model based mode with .

Secondly you use to the sprite that will use this piece of clothes:
Python:
layeredimage girl1:
    always:
        "girl1/body.png"

    group clothes:
        attribute dress1:
            "girl1_dress1"
    [...]

I haven't tested it, but layered images updates in real time, and normally matrixcolor should works follow the usual ATL logic, and therefore accept a variable at value, while updating in real time.

So, it should works.

Edit: ATL stopped updating in real time, you now need to show the image again for it to be updated, will not works :/
 
Last edited:

swimsoot

Member
Game Developer
Mar 14, 2020
314
714
/!\ WARNING /!\
You need Ren'Py version 7.4.6 or higher for this to works, and you need to enable the model based mode with .
First, thanks sooooo much! I will completely give this a try.
Second, can I update my Renpy to the latest version without messing up what I have already done? (I'm currently running 7.3.5)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,234
Second, can I update my Renpy to the latest version without messing up what I have already done? (I'm currently running 7.3.5)
Yes you can, as long as you stay on the branch 7.x, therefore it's probably better to update through the page.
By using a version 7.5.x you'll not miss the bug fixes and improvements, while having a version of Ren'Py fully compatible with your actual code.