> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vivix.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 构建角色可使用的应用

应用是显示在角色旁边的交互面板，例如纸牌游戏、小游戏、产品列表或一组可选择的活动。观众可以在其中点击和输入，角色也能使用应用：发下一张牌、进入下一道题，或介绍观众刚刚选中的产品。

[Vespera](https://docs.vivix.ai/cn/agent/create-character/from-template.md#built-in-templates) 模板就是一个很好的例子：她一边与玩家聊天，一边在旁边的牌桌上发二十一点纸牌。

![Vespera 的角色页面，角色旁边显示二十一点牌桌](https://mintcdn.com/vivix-20d305ce/CoRu-ped4TmOlrpe/images/agent/app-vespera-v3.webp?fit=max\&auto=format\&n=CoRu-ped4TmOlrpe\&q=85\&s=b94b19d6e43f2165e4e728477fc13a9e)

Vespera 的二十一点牌桌。玩家自行下注，由 Vespera 发牌。

## 创建应用

**1. 在对话中描述应用**

打开角色项目，告诉 Agent 你想要什么。建议说明以下四点：

* **外观**：布局、主要元素和视觉风格。
* **运行方式**：规则，以及分数等状态如何变化。
* **观众的操作**：观众点击哪些按钮或输入哪些文字。
* **角色的行为**：角色会自行执行哪些操作，以及如何回应观众。

**2. 在 Game preview 中检查**

应用准备好后，对话中会出现一张 **Game preview** 卡片。点击 **Open preview** 可以单独试用应用；这不会开始对话，也不会消耗点数。

**3. 与角色一起试用**

打开 **Live preview** 面板并点击 **Talk to character**。让角色执行一项操作，同时亲自在应用中点击，观察角色如何回应。

**4. 持续完善**

告诉 Agent 要修改什么，例如布局、规则或角色的回应方式。每次修改后都会出现一张新的 **Game preview** 卡片，方便你先检查，再进行实时试用。

## 示例：与宠物互动的小游戏

Toffee 模板会推荐以下请求。它可以创建一款完整的游戏：

```text wrap theme={null}
Create an interactive "Carrot or Tissue" game that I can play with a kitten.

Use a retro arcade pixel-art style. Place a pixel kitten in the center, with a carrot on one side and a tissue on the other. Show the number of food cans in the top-right corner, starting at 2. Make the experience cute and playful, with arcade-style pixel animations and sound effects.

The user sends commands through the input field. When the user enters "carrot" or "tissue", the kitten should visibly pause to think, looking left and right, hesitating, tilting its head, or tentatively reaching out with a paw before choosing one of the two items. Its choice must not always be correct; support both correct and incorrect answers.

If the kitten picks the item matching the command, add 1 food can, play a pixel celebration animation, and display "Great job!" If it picks the wrong item, subtract 1 food can, play a confused or disappointed kitten animation, and show feedback that the answer was incorrect.

After each round, return to the waiting state and keep the current food-can count so the user can continue. Clearly show the waiting, thinking, choosing, correct, and incorrect states. If the input is neither "carrot" nor "tissue", do not start a round or change the food-can count. Ask the user to enter "carrot" or "tissue".
```

## 更多思路

![一位占卜师角色及其星座应用，可选择星座、抽取幸运牌并显示解读](https://mintcdn.com/vivix-20d305ce/CoRu-ped4TmOlrpe/images/agent/app-momo-v3.webp?fit=max\&auto=format\&n=CoRu-ped4TmOlrpe\&q=85\&s=ce64ae2046cf061ebae6031de6e87358)

星座应用：观众选择自己的星座并抽取幸运牌，向角色提问后会显示解读。

| 应用 | 请求示例 |
| - | - |
| 产品列表 | 添加一个包含这三件产品的产品列表。观众选择后，让角色介绍相应产品。 |
| 单个产品卡片 | 显示该商品的产品卡片，其中包含价格和商店页面链接。 |
| 活动选择器 | 添加一个包含三项活动的面板，供观众选择，并让角色开始观众选中的活动。 |
| 问答计分板 | 为问答添加计分板。观众回答正确时，由角色加一分。 |

> [!TIP]
>
> 除非你提出其他要求，否则产品卡片、产品列表和活动选择器会使用 Vivix 标准样式。只需描述想要的风格即可。

> [!NOTE]
>
> 应用会改变角色旁边面板中显示的内容。如果还希望观众做出选择时，角色本身的场景或服装也随之变化，请在请求中明确说明。请参阅[表演指定内容](https://docs.vivix.ai/cn/agent/capabilities/performance.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.