Character
Character controls the dialogues of the character.
Note: Character do not control the appearance of the character or image. For that, you can use Image.
Public Method
constructor
name: string | null
- If null, then it is a narrator. Narrator do not show any name in the dialogue box.config?: DeepPartial<CharacterConfig>
- CharacterConfig
[[Callable]]
The character.say
can be used as a tag function.
character`Hello, ${Word.color("Alice", "#f00")}!`, // will output "Hello, Alice" with "Alice" in red color
// is equivalent to
character.say`Hello, ${Word.color("Alice", "#f00")}!`
Note: This short-hand is not chainable using some packaging tools like Webpack.
scene.action([ character`sentence 1` `sentence 2`, // this will throw an error ]);
Chainable Method
say
Overload 1 of 4
Say a sentence.
character
.say("Good morning!")
.say("How are you?")
content: string
- The content of the sentenceconfig?: SentenceUserConfig
- SentenceUserConfig
Overload 2 of 4
Use custom Sentence object.
character.say(
new Sentence(character, [
"Good morning, I am ",
new Word("Alice", {color: "#f00"}), // Some words can be colored
])
) // will output "Good morning, I am Alice" with "Alice" in red color
Note: The dialogues's name will be the same as the sentence's name.
content: Sentence
- See Sentence
Overload 3 of 4
Use mixed content of string and Word object.
character.say([
"Hello, ",
new Word("Alice", {color: "#f00"}), // Some words can be colored
]) // will output "Hello, Alice" with "Alice" in red color
content: SentencePrompt
- See SentencePromptconfig?: SentenceUserConfig
- SentenceUserConfig
Overload 4 of 4
Use short-hand for SentencePrompt.
character.say`Hello, ${Word.color("Alice", "#f00")}!` // will output "Hello, Alice" with "Alice" in red color
texts: TemplateStringsArray
- The template string array...words: SingleWord[]
- SingleWord
setName
Set the name of the character.
character
.setName("Alice (angry)")
.say("What do you want?")
name: string
- The name of the character
apply
This is a special alias of say
. It proxies the tag to the say
method.
Note: Using some packaging tools like Webpack, you can't chain this method like this:
scene.action([ character`sentence 1` `sentence 2`, ]);
But you still can chain other methods after it:
scene.action([ character`sentence 1`.setName("Alice"), ]);
This method shortens the code when the character is saying only one sentence.
scene.action([
character`Hello, ${Word.color("Alice", "#f00")}!`,
]);
texts: TemplateStringsArray
- The template string array...words: SingleWord[]
- SingleWord