Input
The Scar::Input
class is an input manager. It supports digital and analog inputs from arbitrary sources. It does not really query inputs itself, it is rather a wrapper where you can define some input method and check it easily via a symbol instead of having to call sfml or native methods.
An instance of it has to be passed to your app because you might want to subclass and add some other functionality to it or have separate input managers for multiple windows.
You define an input via the Input#bind_digital
or Input#bind_axis
functions. Both receive a symbol and a block as arguments. The symbol is the identifier for querying the input. The block should return if the input is active for digital inputs and a float value for analog axis inputs. You may define multiple digital input handlers for one symbol.
For simple keyboard inputs, you can use the Input#sf_key
macro to query if that key is currently pressed. Input.bind_digital(:example) { Input.sf_key(:Space) }
To query the input, you use the Input#active?
(digital) and Input#axis
methods.
Last updated