Automated text box transitions / animations?

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
koteosa
Newbie
Posts: 6
Joined: Fri Feb 27, 2015 1:06 am
Projects: YDS, Unnamed project
Tumblr: koteosa
Deviantart: koteosa
Contact:

Automated text box transitions / animations?

#1 Post by koteosa » Tue Dec 27, 2016 9:54 am

I want to make the textbox fade in while moving up from the bottom of the screen, and then fade out and move down past the bottom of the screen to dispose, similar to the textboxes in Persona 3. I also want the text to dissolve between messages, but not the box, just like in P3.

Making the box hide whenever there's a pause or scene transition would be helpful too, as well as preventing the textbox and text from disappearing whenever a choice is displayed.

I'd much rather not have to use a method that involves me writing it out everytime a box needs to be shown or hidden. Using stuff like "window show pushup" makes the entire screen move (which is headache inducing as well as not what I want) and "window show/hide dissolve" or even just "with dissolve" at the end of dialogue isn't enough for what I want, plus it isn't automated (aka it doesn't happen automatically)... having "with dissolve" at the end of every piece of dialogue is too ridiculous.

I don't know much about how to use ren'py, I'm much more used to rpg maker, so I don't really how how to accomplish any of this. Any tips? Apologies if I'm not being clear enough with what I'm trying to do.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Automated text box transitions / animations?

#2 Post by Divona » Tue Dec 27, 2016 10:29 am

Here I have to used Transform and ATL Function, and some edit to "screen say()" in "screens.rpy" to get it to work. Pretty much assign transform to the "text box", and use extra modules to help check when to display transformation, and when not to. If not, it will just keep animate for every line of text. Here are the code:

In "options.rpy", edit the following code for dissolve transition from .2 to .5:

Code: Select all

define config.window = "auto"

## Transition used to show and hide the dialogue window

define config.window_show_transition = Dissolve(.5)
define config.window_hide_transition = Dissolve(.5)
Put the following code to "script.rpy", outside of "label start:" block.

Code: Select all

init python:
    def say_window_transform(trans, st, at):
        global say_window_show_transform

        if not "say_window_show_transform" in globals():
            say_window_show_transform = False

        if say_window_show_transform == False:
            trans.yoffset = 250
            say_window_show_transform = True

        if say_window_show_transform == True:
            if st > 0.5:
                trans.yoffset = 0
                return None
            else:
                trans.yoffset -= trans.yoffset * st
                return 0
        else:
            return None

    def say_window_transform_reset(trans, st, at):
        global say_window_show_transform
        say_window_show_transform = False


transform say_window_animation:
    on show:
        function say_window_transform
    on hide:
        yoffset 0
        linear 0.3 yoffset 250
        function say_window_tranform_reset

transform text_fade_in:
    alpha 0
    linear 0.5 alpha 1
In "screens.rpy", go to "screen say(who, what):" and edit to match the following code:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        at say_window_animation
        id "window"

        if who is not None:
        
            window:
                style "namebox"
                text who id "who"

        text what id "what" at text_fade_in
In script, just use "window show" and "window hide" to show and hide the dialogue box. Well, you don't actually have to use them as the text box should show and hide automatically like during transition and what not as usual. Just use "window hide" before change the character speaker or when you want to hide the text box, I supposed. Here is the example:

Code: Select all

label start:

    "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    window hide

    "Aliquam aliquam augue id sem ultrices, ac suscipit quam sollicitudin."
    "Integer nec nisl luctus, porta nisl vitae, vulputate leo."
    window hide

    "Suspendisse sit amet suscipit turpis, in lacinia enim."
To preventing the textbox and text from disappearing whenever a choice is displayed, just add text in the choice menu block:

Code: Select all

    menu:
        "This text box is not going any where."

        "Yes":
            pass
        "No":
            pass
Completed:
Image

User avatar
koteosa
Newbie
Posts: 6
Joined: Fri Feb 27, 2015 1:06 am
Projects: YDS, Unnamed project
Tumblr: koteosa
Deviantart: koteosa
Contact:

Re: Automated text box transitions / animations?

#3 Post by koteosa » Wed Dec 28, 2016 4:46 am

AH thank you!! This works perfectly!

Post Reply

Who is online

Users browsing this forum: No registered users