O'Reilly logo

SFML Game Development by Henrik Vogelius Hansson, Artur Moreira, Jan Haller

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

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 ...

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