叙事使用 JS/TS 进行叙事
输入提示
说明如何在 Pixi’VN 中提示玩家输入内容,包括输入请求的使用方式、获取与移除。
UI 界面
您可以在 界面示例 部分找到输入提示对话框 UI 的示例。
ink
你可以在 ink 语法中使用此方法。 请参阅 此处 了解更多信息。
在视觉小说中,您可能需要要求玩家输入文本、数字、日期或其他值。
Pixi’VN 提供了处理输入提示的函数。 开发者可以要求玩家输入一个值(游戏将在提供值之前不会继续),而 UI 负责显示提示。
请求
要提示玩家进行输入,请使用 narration.requestInput 函数。
import { narration, newLabel } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
() => {
narration.dialogue = "Hello";
},
() => {
narration.dialogue = "What is your name?";
narration.requestInput({ type: "string" });
},
() => {
narration.dialogue = `My name is ${narration.inputValue}`;
},
() => {
narration.dialogue = "How old are you?";
narration.requestInput({ type: "number" }, 18);
},
() => {
narration.dialogue = `I am ${narration.inputValue} years old`;
},
() => {
narration.dialogue = "Describe who you are:";
narration.requestInput({ type: "html textarea" });
},
() => {
narration.dialogue = `${narration.inputValue}`;
},
() => {
narration.dialogue = "Restart";
},
]);获取
要获取输入提示信息,请使用:
if (narration.isRequiredInput) {
openInputModal(narration.inputType);
}移除
要移除输入提示请求,请使用 narration.removeInputRequest。
narration.removeInputRequest();