> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-zh/mian-xiang-yi-dong-duan-gou-jian/kai-fa/input-on-mobile.md).

# 移动端输入

在 Decentraland 移动客户端中，输入动作如何映射为触控。

Decentraland 的输入系统专为跨设备设计。同一套 `InputAction` 枚举既用于 SDK 在桌面端公开的输入，也会映射到移动端的屏幕控件，因此大多数场景无需任何修改即可运行。不过，针对触控开发时，有几条规则和注意事项值得了解。

有关完整的输入模型，请参阅 [点击事件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/click-events.md)。本页重点介绍移动端特有的内容。

<figure><img src="https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-3f9b9411cb70df33cba905d3a560fb1bb7ceb258%2Ffull-input.webp?alt=media" alt="The on-screen controls with the + menu expanded, showing every input button"><figcaption><p>展开“+”菜单后的屏幕控件——显示所有输入动作</p></figcaption></figure>

## 触控操作的映射方式

桌面端支持的每个 `InputAction` 在移动客户端上也都可用——屏幕控件只是将触控映射到相同的 SDK 输入。这意味着，依赖标准 `InputAction` 值的任何场景都能开箱即用地在移动端运行。

屏幕控件的映射方式如下：

* **屏幕摇杆** — 控制 `IA_FORWARD` / `IA_BACKWARD` / `IA_LEFT` / `IA_RIGHT` 以及化身移动。
* **交互按钮（右下角）** — 触发 `IA_POINTER` （对应桌面端的鼠标左键），作用于玩家瞄准的目标。
* **E 按钮** — 触发 `IA_PRIMARY` （对应桌面端的 `E` 键）。
* **F 按钮** — 触发 `IA_SECONDARY` （对应桌面端的 `F` 键）。默认隐藏（见下文）。
* **跳跃按钮** — 触发 `IA_JUMP` （对应桌面端的 `Space` 键）。这是 HUD 上最大的按钮，始终方便触及。
* **1 / 2 / 3 / 4 按钮** — 分别触发 `IA_ACTION_3` / `IA_ACTION_4` / `IA_ACTION_5` / `IA_ACTION_6` 。默认隐藏（见下文）。
* **拖动摄像机** —旋转摄像机；不会作为 `InputAction`.

## 自定义控件

场景可以重新配置屏幕控件——隐藏摇杆或准星、隐藏任意按钮（包括跳跃按钮）、更改中央按钮的功能、替换按钮图标，或完全用自定义 UI 取代原生控件。请参阅 [屏幕控件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/touch-screen-controls.md) 和 [UI 输入绑定](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/2d-ui/ui_input_binding.md).

<figure><img src="https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-e8fa39c0bb21eb9c2ff7949a101321cc1549f937%2Fcustom-main-action.webp?alt=media" alt="Customized on-screen controls"><figcaption><p>自定义 HUD：更换图标后的中央按钮已映射到其他操作</p></figcaption></figure>

## 移动设备上应避免用于关键操作的输入

每个 `InputAction` 都可以映射到屏幕按钮，但使用 SDK 7.32.0 或更高版本构建的场景，默认只显示三个按钮：交互按钮、E 按钮和跳跃按钮。 `IA_SECONDARY` （F）和 `IA_ACTION_3`–`IA_ACTION_6` （即 `1`/`2`/`3`/`4` 按钮） **默认隐藏**，因此如果场景没有显示对应按钮，绑定到这些输入的关键操作在手机上就没有可用按钮。在较旧的 SDK 中，八个按钮都会显示，但优先级较低的按钮会收纳在“+”溢出菜单后面，游戏过程中不容易触及。

除非场景通过 [屏幕控件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/touch-screen-controls.md)明确显示这些按钮，否则请避免将关键操作绑定到：

* `IA_SECONDARY` — 桌面端的 `F` 键 / 移动端的 `F` 按钮
* `IA_ACTION_3` — 桌面端的 `1` 键 / 移动端的 `1` 按钮
* `IA_ACTION_4` — 桌面端的 `2` 键 / 移动端的 `2` 按钮
* `IA_ACTION_5` — 桌面端的 `3` 键 / 移动端的 `3` 按钮
* `IA_ACTION_6` — 桌面端的 `4` 键 / 移动端的 `4` 按钮

建议改用：

* `IA_POINTER` 用于主要的点击 / 交互按钮
* `IA_PRIMARY` 用于 E 按钮操作
* `IA_JUMP` 当某个操作自然地对应跳跃时（它是移动端 HUD 上尺寸最大、最容易触及的按钮）
* 基于接近的触发器（参见 [接近事件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/proximity-events.md)），适用于玩家靠近某个实体时应自动触发的操作

## 光标锁定

这个 [`PointerLock` 组件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/click-events.md#lock-or-unlock-the-cursor) 是桌面客户端中的概念（鼠标光标锁定与否）。它不适用于移动端的触摸操作，因此可以放心地将它留在场景中——它在那里不会产生任何效果。

## 相关内容

* [屏幕控件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/touch-screen-controls.md)
* [UI 输入绑定](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/2d-ui/ui_input_binding.md)
* [点击事件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/click-events.md)
* [接近事件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/proximity-events.md)
* [在代码中检测平台](https://docs.decentraland.org/creator/content-creator-zh/mian-xiang-yi-dong-duan-gou-jian/kai-fa/detect-platform.md)
* [移动端 UI 最佳实践](https://docs.decentraland.org/creator/content-creator-zh/mian-xiang-yi-dong-duan-gou-jian/kai-fa/ui-best-practices.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-zh/mian-xiang-yi-dong-duan-gou-jian/kai-fa/input-on-mobile.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
