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 labels updateLabels(); auto backButton = std::make_shared<GUI::Button>(...); backButton->setPosition(100, 375); backButton->setText("Back"); backButton->setCallback([this] () ...