Making dialogue box fade in and out. [SOLVED]

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
User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Making dialogue box fade in and out. [SOLVED]

#1 Post by TellerFarsight »

Hi all,
I want to make it such that every time a new character speaks, the dialogue box very briefly fades out and back in, like in Devil Survivor. I think I should be able to fanaggle a way of doing it using window show and window hide statements, but is there some way to maybe bake that into the character definitions or into the whole UI?
Last edited by TellerFarsight on Thu Jun 15, 2017 8:53 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Making dialogue box fade in and out.

#2 Post by PyTom »

Here's a fairly complex character callback that does it.

Code: Select all

default last_character = None

init python:

    class WindowCallback(object):
        def __init__(self, name):
            self.name =  name

        def __call__(self, event, interact=True, **kwargs):

            global last_character

            if (not interact) or (event != "begin"):
                return

            if self.name == last_character:
                return

            if last_character is None:
                last_character = self.name
                return

            _window_hide(dissolve)
            _window_show(dissolve)

            last_character = self.name

define e = Character("Eileen", callback=WindowCallback("eileen"))
define l = Character("Lucy", callback=WindowCallback("lucy"))
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Making dialogue box fade in and out.

#3 Post by TellerFarsight »

NameError: name 'WindowCallback' is not defined

First of all, thanks a bunch PyTom for looking into this. I'm very new to Ren'Py and it's taking me a while to understand this, but this is the error I get back when trying to use it.
If it's not too much to ask, can you walk me through what I'm looking at here?

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Making dialogue box fade in and out.

#4 Post by Donmai »

You are probably defining your characters before the python block has run.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Making dialogue box fade in and out.

#5 Post by TellerFarsight »

You are 100% correct and I can't believe I made that mistake. It totally works. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users