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.
Code: Select all
# Lead
define lead = Character("Lead", color="#C8B6F5", image="lead_animated", callback=lead_lip_flap, )
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"
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