You are on page 1of 1

Ren'Py: Quick example of adding lip

ap/animation to a talking character


@ARGENT GAMES · MAR 8, 2021 · 2 MIN READ

Short example of having an animation occur while a


Game Dev Blog character is talking, such as blinking or mouth
movement.

Creating LGBTQ+ narrative-driven


games

DMR beta
Home The DMR beta is still ongoing, and all routes are
available to play. If you want to join in, be sure to
Games subscribe to the Throne tier on our Patreon!


Tags
Ren’Py character talking
animation

Ask

We received a question about adding lip ap


animation while a character is talking, so here’s a
short example. It works with layeredimages by treating
them the same as an image . We haven’t
benchmarked it to see if doing it this way makes you
lose out on the predicting/optimization powers of
layeredimages , however. If you benchmark it, we’d love
to hear about the results.

De ne the base sprite ( layeredimage ).

layeredimage taza_base:
always "images/sprites/taza/resize/base.png"

if taza_bow:
"images/sprites/taza/resize/bow.png"

group mouth prefix "m":


attribute n default "images/sprites/taza/resi

De ne the animated image.

image taza talking:


"taza m_n"
pause .25
"taza m_5"
pause .3
"taza m_4"
pause .2
repeat

De ne the lip ap callback event.

init python:
def taza_lip_flap(event,**kwargs):
# when the dialogue event is over, set Taza t
# we don't want him to continue moving his mo
# are speaking.
if event == "end":
renpy.show("taza m_n")
# show the animated image
else:
renpy.show("taza talking")

De ne the character.

cter(_("Sylvie"),callback=taza_lip_flap,image="taza")

Use the character.

label start:
""
show taza
"hello the weather is nice"
t "Lorem ipsum"

Code adapted from Mkol103 on the LemmaSoft forums.

Questions or
Comments?
Feel free to send in any AG-related questions! Our Ask
Box is always open.

Thanks so much for all of your amazing support, and


stay safe out there!

JOIN ARGENT GAMES ON:

AG Twitter | Discord | Patreon

Devlog Ren'py Codesnippet

Related posts

Ren'Py: Rede ning characters to make the writer's job a little easier.
Community event on Saturday!
Ren'Py: Cleaned up the glossary code for Your Dry Delight
Ren'Py: Showing a screen with an animation on click

© This post is licensed under a Creative Commons Attribution-


NonCommercial 4.0 International License,please give source if you
wish to quote or reproduce.This post was published 188 days ago,
content in the post may be inaccurate, even wrong now, please take
risk yourself.

You might also like