38 lines
692 B
Markdown
38 lines
692 B
Markdown
# InputManager::GetButton
|
|
|
|
查询一个具名逻辑按钮当前是否按下。
|
|
|
|
```cpp
|
|
bool GetButton(const Containers::String& buttonName) const;
|
|
```
|
|
|
|
## 行为说明
|
|
|
|
当前逻辑按钮只是“名字到 `KeyCode`”的映射。这个方法会:
|
|
|
|
1. 查找 `buttonName`
|
|
2. 如果找到,则调用 `IsKeyDown(mappedKey)`
|
|
3. 如果没找到,则返回 `false`
|
|
|
|
## 参数
|
|
|
|
- `buttonName` - 逻辑按钮名称。
|
|
|
|
## 返回值
|
|
|
|
- `bool` - 当前是否按下。
|
|
|
|
## 示例
|
|
|
|
```cpp
|
|
if (XCEngine::Input::InputManager::Get().GetButton("Jump")) {
|
|
// ...
|
|
}
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [返回类型总览](InputManager.md)
|
|
- [GetButtonDown](GetButtonDown.md)
|
|
- [RegisterButton](RegisterButton.md)
|