SFML community forums

Help => General => Topic started by: RevertiveDeath on April 08, 2015, 11:40:21 pm

Title: SFML Game Developmet - Problem With Commands
Post by: RevertiveDeath on April 08, 2015, 11:40:21 pm
So I have been following the book SFML Game Development and I am right at the end of chapter 4 (Where we bind keys to actions). The code I have is:

Player::Player()
{
    mKeyBinding[sf::Keyboard::W] = MoveUp;
    mKeyBinding[sf::Keyboard::A] = MoveLeft;
    mKeyBinding[sf::Keyboard::S] = MoveDown;
    mKeyBinding[sf::Keyboard::D] = MoveRight;

    mActionBinding[MoveUp].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.f, -0.1f * dt.asSeconds());
    };

    mActionBinding[MoveLeft].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(-0.1f * dt.asSeconds(), 0.f);
    };

    mActionBinding[MoveDown].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.f, 0.1f * dt.asSeconds());
    };

    mActionBinding[MoveRight].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.1f * dt.asSeconds(), 0.f);
    };

    for(auto &pair : mActionBinding)
        pair.second.category = Category::PlayerAircraft;
}
 

and for some reason I can move up down and right but not to the left. I have looked all over my code and compared it to the source code: https://github.com/SFML/SFML-Game-Development-Book/tree/master/04_Input (https://github.com/SFML/SFML-Game-Development-Book/tree/master/04_Input)

Any ideas why I can't move left?
Title: Re: SFML Game Developmet - Problem With Commands
Post by: eXpl0it3r on April 09, 2015, 12:27:28 am
Start your debugger and find out.