updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
23
game/scripts/action_edges.gd
Normal file
23
game/scripts/action_edges.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class_name ActionEdges
|
||||
extends RefCounted
|
||||
## Per-tick "just pressed" for input actions. A press counts once, either from its input event
|
||||
## (note(), so a tap between two ticks still registers) or from the action turning pressed since
|
||||
## the previous poll (which also covers simulated input). Poll every action once per tick.
|
||||
|
||||
var _held := {}
|
||||
var _requested := {}
|
||||
|
||||
|
||||
func note(event: InputEvent, actions: Array) -> void:
|
||||
for a in actions:
|
||||
if event.is_action_pressed(a, false):
|
||||
_requested[a] = true
|
||||
|
||||
|
||||
func pressed(action: StringName) -> bool:
|
||||
var held := Input.is_action_pressed(action)
|
||||
var was: bool = _held.get(action, false)
|
||||
_held[action] = held
|
||||
var requested: bool = _requested.get(action, false)
|
||||
_requested.erase(action)
|
||||
return requested or (held and not was)
|
||||
Loading…
Add table
Add a link
Reference in a new issue