叙事使用 JS/TS 进行叙事
输入提示
说明如何在 Pixi’VN 中提示玩家输入内容,包括输入请求的使用方式、获取与移除。
UI 界面
您可以在 界面示例 部分找到输入提示对话框 UI 的示例。
ink
你可以在 ink 语法中使用此方法。 请参阅 此处 了解更多信息。
在视觉小说中,您可能需要要求玩家输入文本、数字、日期或其他值。
Pixi’VN 提供了处理输入提示的函数。 开发者可以要求玩家输入一个值(游戏将在提供值之前不会继续),而 UI 负责显示提示。
请求
To prompt the player for input, use the narration.input.request function.
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);
}移除
To remove the input prompt request, use narration.input.removeRequest.
narration.input.removeRequest();