O'Reilly logo

SFML Game Development By Example by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Expanding the event manager

GUI events need to be handled for every possible state of the application in order to keep them from piling up, much like SFML events. In order to avoid writing all of that extra code, we're going to use something that was built solely for the purpose of handling them: the event manager.

Let's start by expanding the EventType enumeration to support GUI events:

enum class EventType{ 
  ...
  Keyboard = sf::Event::Count + 1, Mouse, Joystick,
  GUI_Click, GUI_Release, GUI_Hover, GUI_Leave
};

It's important to keep these custom event types at the very bottom of the structure because of the way the code we've written in the past works.

Our previous raw implementation of the EventManager class relied on the fact that any given event ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required