Events
When Game::tick()
is called, cerlib polls events that occur in the system and stores
them in a queue. This queue is emptied automatically at the beginning of every game tick.
An event is defined as a type switch (std::variant
) of concrete event types:
You can handle events using the Game::handleEvents()
method:
The cerIgnoreEvent
identifier is required in order to ignore all other event types.
It’s implemented as a convenience macro that just represents a [](auto){}
lambda, which is
a closure that accepts any remaining type and discards it.
Iterate events manually
If you have special requirements for event processing, you can iterate the game’s event queue manually.
The Game::events()
method returns a span of all currently queued events.