Transitions are a way to manipulate displayables in renpy, be it a background, a character or even GUI elements like a button. There are many predefined transitions that we can already use out of the box, or we can even define our own transitions if we want something special, however in this basic tutorial we will only use the predefined ones (the custom transitions will be explained in an advanced tutorial in the future).
We will create our own fade where we quickly fade out to white color and a little more slowly fade back in. This has a similar effect to a flash. Fade(.25, 0.1, .75, color="#fff") here, #fff is the hex value for the color white.
renpy fade to black
We can already get the approximate distance to the camera by taking the 4th component of the screen position variable. After we have that we can then remap it to be 0 at the closest distance where surface is completely hidden and 1 at the furthest distance where the surface is completely visible. This operation is like the opposite of a linear interpolation and we can do it by first ensuring the zero is correct by subtracting the minimum fade distance from the distance and then dividing the result by the different between the maximum and minimum fade distance to move the point that was equal to the maximum before to 1. 2ff7e9595c
Comments