> 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/wei-yi-dong-duan-gou-jian/kai-fa/input-on-mobile.md).

# 移动端输入

输入动作如何映射到 Decentraland 移动客户端上的触控。

Decentraland 的输入系统设计为与设备无关。相同的 `InputAction` SDK 在桌面端暴露的枚举也会通过移动端的屏幕控件进行路由，因此大多数场景无需任何改动即可运行。不过，在为触摸设备开发时，有一些规则和注意事项值得了解。

完整的输入模型请参见 [点击事件](/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-cd340dccaecaab8e4408b9d43a91b84fab32afcf%2Ffull-input.jpg?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` （桌面端的 `空格` 键）。这是 HUD 上最大的按钮，始终很容易触及。
* **1 / 2 / 3 / 4 按钮** ——触发 `IA_ACTION_3` / `IA_ACTION_4` / `IA_ACTION_5` / `IA_ACTION_6` 分别对应。这些按钮位于二级菜单后面（见下文）。
* **拖动摄像机** ——旋转摄像机；不作为 `InputAction`.

## 控件自定义

场景可以重新配置屏幕控件——隐藏摇杆或准星，隐藏任意按钮（包括跳跃按钮），更改中央按钮的功能，替换按钮图标，或者完全用自定义 UI 取代原生控件。参见 [屏幕控制](/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/touch-screen-controls.md) 和 [UI 输入绑定](/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-0eef110595612782808b16d7733171deeb560f16%2Fcustom-main-action.jpg?alt=media" alt="Customized on-screen controls"><figcaption><p>自定义 HUD：重新设置图标的中央按钮映射到另一项操作</p></figcaption></figure>

## 在移动端应避免用于关键操作的输入

所有 `InputAction` 值在移动端都可使用，但 `IA_ACTION_3`–`IA_ACTION_6` （桌面端的 `1`/`2`/`3`/`4` 按钮）隐藏在二级菜单后面，而且 **在游戏过程中不容易触及**。如果你的场景将它们用作主要操作，移动端玩家将无法方便地触发它们。

避免将关键操作绑定到：

* `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_SECONDARY` 用于 F 按钮操作
* `IA_JUMP` 当某个操作自然对应跳跃时（它是移动端 HUD 上最大、最容易触及的按钮）
* 基于距离的触发器（参见 [接近事件](/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/proximity-events.md)）当某个操作应在玩家接近实体时自动触发

## 光标锁定

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

## 相关

* [屏幕控制](/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/touch-screen-controls.md)
* [UI 输入绑定](/creator/content-creator-zh/chang-jing-sdk7/2d-ui/ui_input_binding.md)
* [点击事件](/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/click-events.md)
* [接近事件](/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/proximity-events.md)
* [从代码中检测平台](/creator/content-creator-zh/wei-yi-dong-duan-gou-jian/kai-fa/detect-platform.md)
* [移动端 UI 最佳实践](/creator/content-creator-zh/wei-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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
