[SOLVED]Applying animations/transformations to the textbox

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
Skyrius
Newbie
Posts: 12
Joined: Sat Oct 01, 2011 2:15 pm
Contact:

[SOLVED]Applying animations/transformations to the textbox

#1 Post by Skyrius »

Hey all, so I was reading through this old thread: viewtopic.php?t=26818

Which unfortunately is a bit obsolete due to the changes to the screen.rpy over the course of multiple updates, but I was trying to update the solution to work with the current ren'py engine. The example is for a shaking textbox, but I think it can be generalized to any user defined animations, which would let you do a lot of nifty stuff with the textbox.

I thought about using the on statement, but unfortunately that makes it so the ALL the say screens will use this effect, rather that having one particular line cause the animation.

Code: Select all

transform textshake:
    on show:
        Shake(None, 1.0, dist=5)

Code: Select all

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

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

        text what id "what"       
        at textshake
^doesn't quite work, but something like that

I feel like the below should still work since the show_arguments passes whatever you put after 'show_' as an argument to the say screen.

Code: Select all

define e = Character('Eileen', color="#c8ffc8")
define e_shake = Character('Eileen', kind=e, show_window_transform=Shake(None, 1.0, dist=5))
Though unfortunately window_transform I believe is the old variable used in previous versions of screen.rpy

So maybe adding an additional argument to the new say screen?

Code: Select all

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

    window:
        ...
        make use of effect somewhere here?
I'm most likely missing something very obvious on account of not using python very often XD

There is one other way I could think of, which is define a custom screen for every type of animation, but I feel like there should be a way to generalize it so you can just pass an argument instead of having to define 5 different screens

Code: Select all

screen shakescreen(who, what):
    window id "window":
        vbox at 'user_defined_transform':
            spacing 10
            ...etc
^for example, you'd need a bunch of those (I think)

Skyrius
Newbie
Posts: 12
Joined: Sat Oct 01, 2011 2:15 pm
Contact:

Re: [SOLVED]Applying animations/transformations to the textbox

#2 Post by Skyrius »

nvm, got it working after messing around a bit. The answer was indeed just passing an extra variable, I just derped on my indentations lol.

Code: Select all

transform NullTransform:
    pass

screen say(who, what, window_transform=NullTransform):
    style_prefix "say"

    if window_transform is None:
        window:
            id "window"

            if who is not None:

                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"

            text what id "what"
    else:
        window at window_transform:
            id "window"

            if who is not None:

                window at window_transform:
                    id "namebox"
                    style "namebox"
                    text who id "who"

            text what id "what" 
Just pass in show_window_transform = your_custom_code_here to the say screen (I just made a special character for when the screen needed to do something) and you can make your textbox do all sorts of things, fly around, shake, dissolve, etc, for a specific line. The code above is specifically if you wanna use a transform but I imagine you can also replace it with whatever custom python code you want as well (for non-transform effects)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot]