renpy/doc/cookbook/Lip Flap

From Ren'Py

Jump to: navigation, search

Lip Flap

Sometimes, you want to synchronize a character's lip movements to her dialogue. That's what Lip Flap is for.

First, download lip_flap.rpy, and add it to your game directory. This file contains the definition of the LipFlap function. This function returns an object that can be used in a show statement to produce lip flap.

Function: LipFlap (prefix, default="", suffix=".png", combine=...):

prefix - The prefix of filenames that are used to produce lip flap.

default - The default lip that is used when no parameters is given.

suffix - A suffix that is used.

combine - A function that combines its three arguments (prefix, lip, and suffix) into a displayable. The default combine function is Image(prefix + lip + suffix). This could be changed if you want to, say LiveComposite the lips onto a larger character image.

To use lip flap, first declare an image using LipFlap. Then show that image with a parameter string consisting of alternating lips and delays. It will show the first lip, wait the first delay, show the second lip, wait the second delay, and so on. If the string ends with a lip, it will display that lip forever. If it ends in a delay, it will repeat after that delay has elapsed.

See Blink And Lip Flap for an example of combining this with character blinking.

Example

# Note that Ayaki_ShyA.png, Ayaki_ShyB.png, and Ayaki_ShyC.png all exist in the
# game directory.

init:
    image ayaki shy = LipFlap("Ayaki_Shy", "A", ".png")

label ayaki:

    scene bg whitehouse

    # Show Ayaki with her default lip, A.
    show ayaki shy

    "..."

    # Show Ayaki with varying lips.
    show ayaki shy "A .15 B .20 C .15 A .15 C .15 A"
    "Ayaki" "Whatsoever, things are true."

    return
Personal tools