[SOLVED] Animating text box and name box in say screen

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
Marvin0509
Newbie
Posts: 2
Joined: Thu May 23, 2024 7:24 am
Contact:

[SOLVED] Animating text box and name box in say screen

#1 Post by Marvin0509 »

Hello everyone!

I'm currently facing a problem while trying to animate the text box of the say screen. I have a sequence of 30 images for the text box showing, 60 images for the idle animation, and 30 images again for hiding it. My intention is to have the sequences play when showing, idle, or hiding, meaning that for example the window show and window hide statements should trigger the respective animations, and while characters are speaking the text box loops through the idle animation sequence. I want to do the same for the name box, in that case also triggering when going from the narrator without a displayed name to a character with a name and vice versa.

I managed to have the idle text box animation play by defining the image like this:

Code: Select all

image textbox_dx:
    animation

    xalign 0.5
    yalign 1.0

    "gui/textbox/textbox_idle00.png"
    pause 1/60
    "gui/textbox/textbox_idle01.png"
    pause 1/60
    ...
    "gui/textbox/textbox_idle59.png"
    pause 1/60
    repeat
and then simply putting it in the place of the default text box in the say screen:

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background "textbox_dx"
The problem I face is with playing the show and hide animation sequences. To have it show, I tried modifying the image itself like this:

Code: Select all

image textbox_dx:
    ...

    "gui/textbox/textbox_show00.png"
    pause 1/60
    ...
    "gui/textbox/textbox_show29.png"
    pause 1/60

    block:
        "gui/textbox/textbox_idle00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_idle59.png"
        pause 1/60
        repeat
So the show animation would play once, then the idle animation loops as long as necessary (meaning until the box is hidden). That does work, but only once. Even when the say screen is hidden, and later shown again, the animation sequence does not reset, so when shown again, it's already back in the idle loop and does not go through the show animation again. And that attempt of course doesn't have the hide animation at all yet.

I tried using the on show and on hide events for this, since it seemed like they could be what I'm looking for. I tried using them like this:

Code: Select all

image textbox_dx:
    ...

    on show:
        "gui/textbox/textbox_show00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_show29.png"
        pause 1/60

    on hide:
        "gui/textbox/textbox_hide00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_hide29.png"
        pause 1/60

    block:
        "gui/textbox/textbox_idle00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_idle59.png"
        pause 1/60
        repeat
But either I'm misunderstanding how they work or I'm doing something wrong, because with this, the text box stops showing up at all.

Does anyone here maybe have any ideas on how to tackle this problem? Thanks in advance for any help, it would be greatly appreciated!
Last edited by Marvin0509 on Fri May 31, 2024 2:14 pm, edited 1 time in total.

jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Animating text box and name box in say screen

#2 Post by jeffster »

Try to perhaps experiment with 'replace', 'replaced', 'update':
https://renpy.org/doc/html/atl.html#external-events

Code: Select all

image textbox_dx:
    xalign 0.5
    yalign 1.0
    "gui/textbox/textbox_idle00.png"
    block:
        pause 1/60
        "gui/textbox/textbox_idle01.png"
        ...
        "gui/textbox/textbox_idle59.png"
        pause 1/60
        "gui/textbox/textbox_idle00.png"
        repeat

    on show, replace, update:
        "gui/textbox/textbox_show00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_show29.png"
        pause 1/60

    on hide, replaced:
        ...
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Animating text box and name box in say screen

#3 Post by jeffster »

PS
Marvin0509 wrote: Fri May 24, 2024 2:09 pm Hello everyone!
I think similar topics were discussed, and here's some info:
viewtopic.php?t=41568
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

User avatar
Marvin0509
Newbie
Posts: 2
Joined: Thu May 23, 2024 7:24 am
Contact:

Re: Animating text box and name box in say screen

#4 Post by Marvin0509 »

jeffster wrote: Fri May 24, 2024 4:42 pm Try to perhaps experiment with 'replace', 'replaced', 'update':
<https://renpy.org/doc/html/atl.html#external-events>

Code: Select all

image textbox_dx:
    xalign 0.5
    yalign 1.0
    "gui/textbox/textbox_idle00.png"
    block:
        pause 1/60
        "gui/textbox/textbox_idle01.png"
        ...
        "gui/textbox/textbox_idle59.png"
        pause 1/60
        "gui/textbox/textbox_idle00.png"
        repeat

    on show, replace, update:
        "gui/textbox/textbox_show00.png"
        pause 1/60
        ...
        "gui/textbox/textbox_show29.png"
        pause 1/60

    on hide, replaced:
        ...
Hello Jeffster, thanks for the suggestion. I tried adding the events you suggested, and aside from those you mentioned, I also tried all events that are listed at https://www.renpy.org/doc/html/atl.html#external-events. Still, none of those seem to ever get triggered. I think that either there's an error the way I'm currently defining the image (using the ATL variant of the image statement), or it's because according to https://www.renpy.org/doc/html/screens. ... roperty-at "The show, hide, replace, and replaced external events are delivered to a transform if and only if it is added directly to the screen."

I also read through the thread you linked, and that mostly did the trick. What I did now to get it working was adding a screen that would only be displayed when the say screen is displayed too:

Code: Select all

screen say_background:
    showif renpy.get_screen("say"):
        image "textbox_idle" at textbox_anim
Which displays the idle textbox image, at the custom transform that contains the show and hide animations:

Code: Select all

transform textbox_anim:
    on show:
        "gui/textbox/show/textbox show 00.png"
        1/60
        ...
        "gui/textbox/show/textbox show 29.png"
        1/60

    on hide:
        "gui/textbox/hide/textbox hide 00.png"
        1/60
        ...
        "gui/textbox/hide/textbox hide 29.png"
        1/60
Lastly, I set define config.window_show_transition = Pause(.2) so that the text would start showing slightly delayed such that the animation would have finished enough for the text not to appear on nothing.

In any case, thanks for your help!

jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: [SOLVED] Animating text box and name box in say screen

#5 Post by jeffster »

Yeah, and many thanks to m_from_space for that really smart trick. 8)
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

JosephGray
Newbie
Posts: 1
Joined: Wed May 22, 2024 9:05 am
Contact:

Re: [SOLVED] Animating text box and name box in say screen

#6 Post by JosephGray »

Yes, it is. It helped me also.

Post Reply

Who is online

Users browsing this forum: No registered users