Lip Flap Using Layered Images - Lip Flap Text Syncing Help

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
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Lip Flap Using Layered Images - Lip Flap Text Syncing Help

#1 Post by AvalonMelody »

Good evening!
I've seen a lot of references and the og cookbook page with blinking/lip-flaps using CompositeImages which was how I used to do old sprites, but seeing as Renpy has LayeredImages now I've been working on getting character blinking + lip flap working with LayeredImage sprites.

So far, blinking works perfectly and the lip flap repeats properly on the layered image. I've also used the callbacks to make it so the character will only lip flap when they have dialogue displayed, so no troubles there.

However I've come across a problem where the character won't stop flapping their lips even when all the dialogue in the say window has loaded. (Currently, dialogue is not instant but 30 cps)

What I'd like it to do is to have the character flap their lips and stop when the dialogue has fully loaded, but if the text window is still up, no big deal, there's just quietly blinking as they watch you read.

The codes being used for this are below and any help would be appreciated! Ideally, I'd like to keep using layered images instead of have to switch back to Composite but if that's the only way to assure the character won't talk to ghosts, I'll just grab the old cookbook code. :(

For fixes, I've already tried shuffling the ifs around and the conditional (things like event == "end" or event == "show done", etc) in the callback but that usually ends up with the sprite not flapping at all or not stopping when another character (or the narrator) lines appear. Maybe I'm not using the right combination though?

Also, if there's a way to streamline this or make the code cleaner/more useable for other characters (I'm assuming right now this is the bare minimum though and I'll have to make one of these for each character) that would also be appreciated!

Thanks much for your time!
Avalon



CALLBACK CODE

Code: Select all

# Callbacks
init python:
    def lead_lip_flap(event, interact=True, **kwargs):
        if not interact:
            return
        if event == "show":
            renpy.show("lead_talking") #else talking
            
        elif event == "slow_done" or event == "end":
            renpy.hide ("lead_talking")
            renpy.show("lead_animated smile") #reset to smile lead.
CHARACTER CODE

Code: Select all

# Lead
define lead = Character("Lead", color="#C8B6F5", image="lead_animated", callback=lead_lip_flap, )
LAYERED IMAGE (just in case-)

Code: Select all

layeredimage lead_animated: 
    always:
        "images/Sprites/Lead/lead_base.png"
        
    group eyes:
        attribute blinking default:
            "lead_blinking"

    group brows:
        attribute normal default:
            "images/Sprites/Lead/lead_brows_normal.png"

    group mouth:
        attribute smile default: 
            "images/Sprites/Lead/lead_mouth_smile.png"
            
    group arms:
        attribute hands_open default:
            "images/Sprites/Lead/lead_arms_up.png"
            
ANIMATIONS

Code: Select all

image lead_blinking:
    "images/Sprites/Lead/lead_eyes_normal.png"
    choice:
        pause 4.5
    choice:
        pause 3.5
    choice:
        pause 1.5
    "images/Sprites/Lead/lead_eyes_half.png"
    pause .1
    "images/Sprites/Lead/lead_eyes_closed.png"
    pause .1
    "images/Sprites/Lead/lead_eyes_half.png"
    pause .1
    repeat
    
image lead_talking:
    "images/Sprites/Lead/lead_mouth_smile.png"
    pause .25
    "images/Sprites/Lead/lead_mouth_open.png"
    pause .3
    repeat

User avatar
nyeowmi
Newbie
Posts: 5
Joined: Thu Oct 27, 2022 11:10 pm
Projects: Never Ending Love
Discord: nyeowmi#6969
Contact:

Re: Lip Flap Using Layered Images - Lip Flap Text Syncing Help

#2 Post by nyeowmi »

Did you ever figure out the answer to this? I'd be really curious to hear the answer!

User avatar
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Re: Lip Flap Using Layered Images - Lip Flap Text Syncing Help

#3 Post by AvalonMelody »

nyeowmi wrote: Thu Nov 24, 2022 4:57 am Did you ever figure out the answer to this? I'd be really curious to hear the answer!
Ah, not yet! But I think this reply will help bump the post. Maybe we'll get a response. ^^;; )

Post Reply

Who is online

Users browsing this forum: No registered users