Files
XCEngine/docs/api/XCEngine/Input/InputManager/GetButtonDown.md

36 lines
701 B
Markdown
Raw Normal View History

2026-03-26 16:45:24 +08:00
# InputManager::GetButtonDown
2026-03-26 17:39:53 +08:00
查询一个具名逻辑按钮是否在本帧刚被按下。
2026-03-26 16:45:24 +08:00
```cpp
bool GetButtonDown(const Containers::String& buttonName) const;
```
2026-03-26 17:39:53 +08:00
## 行为说明
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
当前实现把逻辑按钮当作 `KeyCode` 别名处理,因此这个方法等价于对映射后的键调用 `IsKeyPressed()`
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
如果按钮名未注册,返回 `false`
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
## 参数
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
- `buttonName` - 逻辑按钮名称。
## 返回值
- `bool` - 该按钮是否在本帧刚被按下。
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
## 示例
```cpp
if (XCEngine::Input::InputManager::Get().GetButtonDown("Fire1")) {
// ...
2026-03-26 16:45:24 +08:00
}
```
## 相关文档
2026-03-26 17:39:53 +08:00
- [返回类型总览](InputManager.md)
- [GetButton](GetButton.md)
- [GetButtonUp](GetButtonUp.md)