The promised key bindings

We implement a new state; the SettingsState which you access through a button on the menu. What is the purpose for the SettingsState in our example? Currently we have the key bindings inside there. Everything we need has already been implemented with the GUI, so we only have to define the actual state.

The constructor of the SettingsState class one is pretty big so we snip it.

SettingsState::SettingsState(StateStack& stack, Context context) : State(stack, context) , mGUIContainer() { mBackgroundSprite.setTexture(context.textures->get(Textures::TitleScreen)); mBindingButtons[Player::MoveLeft] = std::make_shared<GUI::Button>(...); mBindingLabels[Player::MoveLeft] =std::make_shared<GUI::Label>(...); ... // More buttons and ...

Get SFML Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.