Fade In, Fade Out and animated Letterbox

Hello, this is a module I wrote to facilitate the creation of scene transitions.
Currently youu can only do Fade In and Out, and a fake letterbox effect :smiley:

Demo:
http://i.imgur.com/g8i3bne.gif

You don’t have to use any meshes or animations, just put the script in the camera.

Usage:


from bge import logic
from transitions import *


def main(cont):
    o = cont.owner
    
    if "init" not in o:
        # DON'T CALL THE CONSTRUCTOR MORE THAN ONCE!
        o["fader"] = Fader()
        o["lbox"] = LetterBox()

        o["fader"].color = (0.0, 1.0, 0.0) # Fade to/from green
        o["fader"].time = 1.0 # Fade time in seconds
        o["fader"].wait = 0.5 # wait before fading
        
        o["lbox"].color = (1.0, 0.0, 0.0) # Red letterbox
        o["lbox"].time = 1.0 # LetterBox animation duration in seconds
        o["lbox"].size = 0.2 # LetterBox size. % of the screen height


        o["init"] = 1
    else:
        o["fader"].update()
        o["lbox"].update()
        
        if cont.sensors["FADEIN"].positive:
            o["fader"].fadeIn()
        elif cont.sensors["FADEOUT"].positive:
            o["fader"].fadeOut()
        
        if cont.sensors["SHOW"].positive:
            o["lbox"].show()
        elif cont.sensors["HIDE"].positive:
            o["lbox"].hide()

Grab it here: fader.blend (446 KB)
Press 1: Fade In
Press 2: Fade Out
Press 3: Show Letterbox
Press 4: Hide Letterbox

I hope you enjoy! :smiley:

Great! Thanks for sharing :slight_smile: Very usefull for the ones (like me) who wants to learn openGL.