module SFML::InputQueries
Instance-side helpers — included into App and Scene so user code can call action_pressed? / axis from update etc.
Public Instance Methods
Source
# File lib/sfml/input_actions.rb, line 74 def action_pressed?(action_name) bindings = _resolve_action_bindings[action_name.to_sym] return false unless bindings bindings[:keys].any? { |k| Keyboard.key_pressed?(k) } || bindings[:scancodes].any? { |s| Keyboard.scancode_pressed?(s) } || bindings[:mouse_buttons].any? { |b| Mouse.button_pressed?(b) } || bindings[:joy_buttons].any? { |(j, b)| Joystick.button_pressed?(j, b) } end
Source
# File lib/sfml/input_actions.rb, line 86 def axis(negative:, positive:) pos = action_pressed?(positive) ? 1.0 : 0.0 neg = action_pressed?(negative) ? 1.0 : 0.0 pos - neg end
Synthetic digital axis from two opposing actions. Returns -1.0, 0.0, or +1.0 — never both 1 and -1 (positive wins if both held).