Mirai-Team / mirai-project

C++ library for games making purposes.
Other
3 stars 0 forks source link

Add parameter support in Input Manager #43

Closed Lomadriel closed 9 years ago

Lomadriel commented 9 years ago

Add a support of function parameters in InputManager. (with template) For Instance : std::function<void(int)> funct instead of std::function<void()> funct

CBenoit commented 9 years ago

No need to do something about it, since we can use lambda expressions. By the way, in most of the cases, we will rather prefer to use lambda expressions to call an object method, static functions, or, if you need a function / method with parameters. See, in playerControl example we have that :

    keyboardManager.addBinding("moveRight", sf::Keyboard::Right, [&character](){
        character.moveRight();
    });

But, if we had a method move(std::string direction), we could do as following :

    keyboardManager.addBinding("moveRight", sf::Keyboard::Right, [&character](){
        character.move("right");
    });

No problem :+1:

Lomadriel commented 9 years ago

Indeed