Documentation
Types
SentenceConfig

SentenceConfig

type SentenceConfig = Partial<{
    character: Character | null;
    color: Color;
    voiceId: string | number | null;
    voice: Sound | string | null | undefined
} & Font>;

For Font, see Font.

voice

The voice that will say the sentence.

If you specify the voice, the voiceId will be ignored.

character1.say("hello!", {
    voice: new Sound({
        src: "/your/path/to/voice.mp3"
    })
});

voiceId

VoiceId is a unique identifier for the voice. It can be a string or a number.

For example, if you have a lot of voice files, you can use the voiceId to identify the voice.

const voiceScene = new Scene("voice-scene", {
    voices: {
        "a_1_1": "/your/path/to/voice.mp3"
    }
});
 
voiceScene.action([
    character1
        .say("hello!", {
            voiceId: "a_1_1"
        }),
]);

Or you can use a handler to generate the voiceId.

const voiceScene = new Scene("voice-scene", {
    voices: (id) => `/static/game/sound/bgm/${id}.mp3`
});

character

The character that will say the sentence. Using this property will override the previous character.

color

The color of the sentence.

new Sentence("hello!", {
    color: "red"
});
 
new Sentence("hello!", {
    color: "#ff0000"
});
 
new Sentence("hello!", {
    color: {
        r: 255,
        g: 0,
        b: 0
    }
});