Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Dynamic Key Binding  (Read 4105 times)

0 Members and 1 Guest are viewing this topic.

diseasedtoe

  • Newbie
  • *
  • Posts: 4
    • View Profile
Dynamic Key Binding
« on: July 23, 2011, 01:57:00 am »
Hey guys, I actually have a problem I was hoping you could help me with.  I saw this tutorial a while back, when I using 1.6:

https://github.com/SFML/SFML/wiki/TutorialManageDynamicKeyBinding

however now that I have switched to 2.0, this no longer seems to work for me.  Can you guys help me somehow use this with sfml 2.0, or at least point me in the write direction?  Thanks in advance.

JAssange

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Dynamic Key Binding
« Reply #1 on: July 23, 2011, 05:54:44 am »
GetEvent is now PollEvent and the input system has been revamped. It shouldn't be too hard to convert since that example uses events.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Dynamic Key Binding
« Reply #2 on: July 23, 2011, 04:51:10 pm »
You could also reuse something existing like this :P
Code: [Select]
thor::ActionMap<std::string> map;

//Let's bind the left mouse button to the "Shoot" action
map["Shoot"] = thor::Action(sf::Mouse::Left);

//Let's bind the Return key to the "Jump" action
map["Jump"] = thor::Action(sf::Keyboard::Return);

//Let's bind any of the control keys to the "Use" action
Keys["Use"] = thor::Action(sf::Keyboard::LControl) || thor::Action(sf::Keyboard::RControl);
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: