GFInputDirectionHistory¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/input/history/gf_input_direction_history.gd - 模块:
Standard - 继承:
RefCounted - API:
public - 类别:领域模型 (
domain_model) - 首次版本:
3.17.0
最后按下方向优先的输入历史。 维护动作 ID 到方向向量的按下顺序,适合网格移动、菜单导航或四方向角色控制。 它不读取 InputMap,也不规定动作命名。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 方法 | press_action |
func press_action(action_id: StringName, direction: Vector2i) -> void: |
| 方法 | release_action |
func release_action(action_id: StringName) -> void: |
| 方法 | press_direction |
func press_direction(direction: Vector2i) -> void: |
| 方法 | release_direction |
func release_direction(direction: Vector2i) -> void: |
| 方法 | update_action |
func update_action(action_id: StringName, direction: Vector2i, pressed: bool) -> void: |
| 方法 | get_current_direction |
func get_current_direction() -> Vector2i: |
| 方法 | get_current_action |
func get_current_action() -> StringName: |
| 方法 | get_history |
func get_history() -> Array[StringName]: |
| 方法 | clear |
func clear() -> void: |
方法¶
press_action¶
- API:
public
标记一个方向动作被按下。
参数:
| 名称 | 说明 |
|---|---|
action_id |
动作标识。 |
direction |
方向。 |
release_action¶
- API:
public
标记一个方向动作被释放。
参数:
| 名称 | 说明 |
|---|---|
action_id |
动作标识。 |
press_direction¶
- API:
public
按方向值生成内部动作标识并标记按下。
参数:
| 名称 | 说明 |
|---|---|
direction |
方向。 |
release_direction¶
- API:
public
按方向值生成内部动作标识并标记释放。
参数:
| 名称 | 说明 |
|---|---|
direction |
方向。 |
update_action¶
- API:
public
根据 pressed 状态更新动作。
参数:
| 名称 | 说明 |
|---|---|
action_id |
动作标识。 |
direction |
方向。 |
pressed |
是否按下。 |
get_current_direction¶
- API:
public
获取当前优先方向。
返回:最近按下且尚未释放的方向;没有时返回 Vector2i.ZERO。
get_current_action¶
- API:
public
获取当前优先动作。
返回:最近按下且尚未释放的动作;没有时返回空 StringName。
get_history¶
- API:
public
获取按下历史副本。
返回:动作 ID 列表。
clear¶
- API:
public
清空历史。