Ren'Py memo

Ren'Pyの個人的なメモ

ボイスが鳴っている間だけ口を動かす

参照:Can Lip Flap Be Synched (Sync / Synced) With Voice [solved] - Lemma Soft Forums


python earlyの置き場所:initの下じゃないところ できれば一番上に置く
* and _preferences.get_mute("voice") == Falseはボイスミュートの際に口パクを行わないためのコード 動かしたい場合は該当のコードを消してください

python early:

    # https://lemmasoft.renai.us/forums/viewtopic.php?t=25399
    speaking = None

    def while_speaking(names, speak_d, done_d, st, at):
        if renpy.music.is_playing('voice') and speaking == names and _preferences.get_mute("voice") == False:
            return speak_d, .1
        else:
            return done_d, None

    curried_while_speaking = renpy.curry(while_speaking)

    def WhileSpeaking(names, speaking_d, done_d=Null()):
        curried_while_speaking = renpy.curry(while_speaking)
        return DynamicDisplayable(curried_while_speaking(names, speaking_d, done_d))

    def speaker_callback(names, event, **kwargs):
        global speaking
        speaking = names

    speaker = renpy.curry(speaker_callback)

Character

 define b = Character(_('スーくん'), voice_tag="b", callback=speaker("b"), image="1")


口パクアニメーションの指定

    image 1_talk:
        "1_c_c1" #閉じ口
        choice:
            pause 0.1
        choice:
            pause 0.05
        choice:
            pause 0.01
        "1_c_c6" #中間口
        pause 0.1
        "1_c_c7" #大きく開ける口
        pause 0.1
        repeat

layeredimage

 #キャラクター変数名、口パクアニメーション名、最後に表示される口の画像
    image 1_m1 = WhileSpeaking("b", "1_talk", "1_c_c1.png") 
    image 1_m2 = WhileSpeaking("b", "1_talk", "1_c_c2.png")
    image 1_m3 = WhileSpeaking("b", "1_talk", "1_c_c3.png")
    image 1_m4 = WhileSpeaking("b", "1_talk", "1_c_c4.png")
    image 1_m5 = WhileSpeaking("b", "1_talk", "1_c_c5.png")

    layeredimage 1:
        always "1_base"

        group a:
            attribute a1 default
            attribute a2
            attribute a3
            attribute a4
        group b:
            attribute b1 default
            attribute b2
        group c:
            attribute c0 default
            attribute c1
            attribute c2
            attribute c3
            attribute c4
            attribute c5
            attribute c6
            attribute c7
        group e:
            attribute e0 default
            attribute e1:
                "1_m1"
            attribute e2:
                "1_m2"
            attribute e3:
                "1_m3"
            attribute e4:
                "1_m4"
            attribute e5:
                "1_m5"
        group d:
            attribute d1 default
            attribute d2

使用例

    show 1 a1 b1 e3 with dissolve