ナレーションJS/TSによるナレーション
入力プロンプト
Pixi’VNでプレイヤーへの入力を求める方法について、使用方法、取得、および入力リクエストの削除を含めて説明します。
UI 画面
入力プロンプトダイアログUIの例は、インターフェース例セクションで確認できます。
ink
このメソッドは ink 構文で使用できます。詳細はこちらをご覧ください。
ビジュアルノベルでは、プレイヤーにテキスト、数値、日付、またはその他の値を入力させる必要がある場合があります。
Pixi’VN は入力プロンプトを処理する関数を提供しています。開発者はプレイヤーに値の入力を求めることができ(値が入力されるまでゲームは進行しません)、UI がプロンプトの表示を担当します。
選択の実行
プレイヤーへの入力を求めるには、narration.input.request 関数を使用します。
import { narration, newLabel } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
() => {
narration.dialogue = "Hello";
},
() => {
narration.dialogue = "What is your name?";
narration.input.request({ type: "string" });
},
() => {
narration.dialogue = `My name is ${narration.input.value}`;
},
() => {
narration.dialogue = "How old are you?";
narration.input.request({ type: "number" }, 18);
},
() => {
narration.dialogue = `I am ${narration.input.value} years old`;
},
() => {
narration.dialogue = "Describe who you are:";
narration.input.request({ type: "html textarea" });
},
() => {
narration.dialogue = `${narration.input.value}`;
},
() => {
narration.dialogue = "Restart";
},
]);取得
入力プロンプトの情報を取得するには、以下を使用します。
if (narration.input.isRequired) {
openInputModal(narration.input.type);
}削除
入力プロンプトリクエストを削除するには、narration.input.removeRequest を使用します。
narration.input.removeRequest();