输入支持
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本主题介绍了在 Google Play 游戏电脑版中处理用户输入时的设计注意事项和最佳实践。
Google Play 游戏电脑版依靠鼠标和键盘(而非触摸屏)作为玩家输入方式。在设计鼠标和键盘体验时,应侧重于为台式机或笔记本电脑用户打造卓越用户体验。如需开始设计,请参阅关于 Chromebook 的 Android 应用输入兼容性的指南。
我们建议在设计和构建玩家互动时遵循以下最佳实践。
- 所有目标都应该可通过鼠标点击。
- 所有可滚动的界面都可以通过鼠标滚轮来滚动。
- 悬停光标时突出显示可点击的界面,请运用您的最佳判断,确保既能有助于改善界面导航体验,又避免向用户呈现过多悬停点。
- 为用户提供可快速调出控件的热键。
- 将触摸控件(例如,拇指操纵杆或屏幕上的按钮)替换为鼠标控件和热键。
- 对于移动游戏中需要多点触控手势的操作,请确保可以使用键盘或鼠标控件实现相同的操作(例如,使用鼠标的滚轮替换双指张合)。
如需了解更多详情和最佳实践,请参阅关于针对鼠标和键盘优化 ChromeOS Android 应用的指南。
国际化注意事项
为国际受众群体设计游戏时,请务必在键盘布局设置为游戏支持的每种语言的情况下测试游戏。否则,玩家可能无法使用游戏内聊天等功能。您可以在系统设置中更改输入语言区域设置,所做更改会自动应用于 Google Play Games on PC。在移动设备上,由于您从虚拟键盘接收文本,引擎中的许多问题可能会被隐藏。电脑版常见问题包括:
- 错误处理了“替代图形”键码 (AltGr)。在许多语言区域中,此键用于输入变音符号(例如重音符号)或特定于语言区域的特殊符号(例如地区币种字形)。
- 错误地处理了输入法扩展程序 (IME) 输入。此方法通常用于支持非拉丁字母,允许用户将多次击键操作组合成单个字符。
GameTextInput
和 EditText
已经了解国际键盘布局和输入法。
以下列表包含一些在许多游戏中通用的操作,以及开发者在 Google Play 游戏电脑版中使用的典型实现:
- 使用 Enter 键在文本输入字段中发送信息或提交文本。
- 应可使用 Esc 键取消菜单和对话框。
- 使用 Enter 键浏览故事元素和对话框。
- 使用鼠标滚轮垂直滚动文字。
- 使用鼠标滚轮放大或缩小,尤其是在移动 build 中使用双指张合手势时。
- 使用 W、A、S 和 D 键在地图上向四个方向平移(移动玩家通常使用点击和拖动操作在地图上进行平移)。
尽管这些操作很常见,但您仍应通过输入 SDK 向玩家明确展示这些操作,以确保玩家能通过适当的方式了解这些操作。
兼容模式
默认情况下,Google Play 游戏电脑版会将您的游戏置于“输入兼容模式”。这意味着,当玩家按下鼠标左键时,系统会向游戏发送触摸事件。如需了解详情,请参阅鼠标输入指南。
教程和用户指导
在某些情况下,除了查看鼠标和键盘控件之外,用户还能使用游戏内教程学习如何使用游戏控件。我们建议提供游戏内教程和指导功能,教会用户如何正确使用鼠标和键盘控件,同时为 PC 版游戏移除与触摸控件相关的教程。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Input support\n\nThis topic covers design considerations and best practices for handling user\ninput in Google Play Games on PC.\n\nGoogle Play Games on PC relies on a mouse and keyboard for player input rather\nthan a touchscreen. When designing your mouse and keyboard experience, focus on\nbuilding the best user experience for desktop or laptop PC users. To get\nstarted, see our guide on\n[Android app input compatibility for Chromebooks](/topic/arc/input-compatibility).\n\nBest practices\n--------------\n\nWe recommend the following best practices for designing and building player\ninteractions.\n\n- All targets should be clickable with a mouse.\n- All scrollable surfaces scroll on mouse wheel events.\n- Highlight clickable surfaces when hovered, and use your best judgment to improve UI discovery without overwhelming the user.\n- Provide hotkeys for users to quickly bring up controls.\n- Replace touch-based controls (for example, thumb joysticks or on-screen buttons) with mouse-based controls and hotkeys.\n- For actions in your mobile game that require multi-touch gestures, ensure the same actions are supported with a keyboard or mouse control (for example, using the scroll wheel of the mouse to replace a two-finger pinch).\n\nFor additional details and best practices, see our guide on\n[optimizing your ChromeOS Android app for mouse and keyboard](/topic/arc/optimizing#keyboard).\n\n### Internationalization considerations\n\nWhen designing a game for an international audience, it is important that you\ntest your game with your keyboard layout set to each language supported by your\ngame. Failure to do so may block players from using features such as in-game\nchat. You can change your input locale\n[in your system settings](https://support.microsoft.com/en-us/windows/manage-the-input-and-display-language-settings-in-windows-12a10cb4-8626-9b77-0ccb-5013e0c7c7a2)\nand the changes will apply automatically to Google Play Games on PC. On\nmobile, many issues in your engine may be hidden by the fact that you're\nreceiving text from a virtual keyboard. Common issues on PC include:\n\n- Incorrect handling of \"alternative graphic\" (AltGr) keycodes. In many locales this is used to type diacritical marks such as accents or special locale-specific symbols such as regional currency glyphs.\n- Incorrect handling of [\"input method extension\" (IME)](/reference/android/view/inputmethod/InputMethodManager) inputs. This method is commonly used to support non-Latin alphabets by allowing users to combine several keystrokes into a single character.\n\n[`GameTextInput`](/games/agdk/add-support-for-text-input) and\n[`EditText`](/reference/android/widget/EditText) are already aware of\ninternational keyboard layouts and input methods.\n\n### Recommended input mappings\n\nThe following list includes actions many games have in common, and the typical\nimplementation developers use on Google Play Games on PC:\n\n- Use the enter key to send messages or submit text in text entry fields.\n- Menus and dialogs should be cancellable with the escape key.\n- Use the enter key to progress through story elements and dialog boxes.\n- Use the scroll wheel to scroll text vertically.\n- Use the scroll wheel to zoom in or out, especially if you use a two-finger pinch in your mobile build.\n- Use W, A, S, and D navigate around a map that you'd normally use a click and drag motion on.\n\nEven though these actions are common, you should still explicitly present them\nto the player with the [Input SDK](/games/playgames/input-sdk) to make sure they're\nproperly discoverable.\n\nCompatibility mode\n------------------\n\nGoogle Play Games on PC places your game into \"input compatibility mode\" by\ndefault. This means that when you press the left mouse button, your game is\ngiven a touch event. See the [mouse input](/games/playgames/input-mouse) guide for more\ninformation.\n\nTutorials and user education\n----------------------------\n\nIn some cases, users can benefit from in-game tutorials that teach them the\ncontrols to the game, in addition to being able to view the mouse and keyboard\ncontrols. We recommend including in-game tutorials and educational features with\nthe correct controls for mouse and keyboard, and removing tutorials relevant to\ntouch-based controls for the PC version of your game."]]