Managing user inputs
Managing the events received from the user is a really important topic. SFML provides us with two different approaches. The first is by polling the events received from a sf::Window
instance, and the other is by checking the state in real time of an entry.
First of all, what is an event?
Generally, an event is an object that is triggered when something changes/happens. They are OS-dependent, but SFML provides us with a nice object to handle them in an OS-independent way. This is the sf::Event
class. This class deals with a vast number of events, as follows:
- Windows contains four different kinds of events. They are as follows:
- Close
- Resize
- Gain/lose focus
- The mouse pointer goes in/out of the window
- There are three events for the mouse. They are as follows:
- Move
- Key press/release
- Wheel press, release, or move
- The keyboard contains two events. They are as follows:
- Keys press/release
- Text entered
- The joystick is also managed with four events. They are as follows:
- Connected/disconnected...