SFML community forums
Help => Window => Topic started by: kurasu1415 on October 09, 2012, 10:56:42 pm
-
Hey guys,
So I want to be able to call Keyboard::isPressed() in another class. Basically, I have a class that handles mapping keyboard and gamepad input. Do I need to have a pointer to my original sf::Window to call Keyboard::isPressed() ? If not, what do I need to pass to my class/function in order to check what keys are pressed?
-
Nothing. ;D
Just include the needed header and start using sf::Keyboard. sf::Keyboard doesn't depend on events or anything it works on its own.
Btw you could've just tested this out (or read the documentation)... ::)
-
I looked over the docs, and I didn't see where it said I could call it from anywhere I wanted. I didn't test because I assumed it would be more difficult than that. Thanks for the help.
-
I looked over the docs, and I didn't see where it said I could call it from anywhere I wanted. I didn't test because I assumed it would be more difficult than that. Thanks for the help.
But it also didn't say anything about that you have to call it only in situation x, thus you usually can conclude the contrary. ;)
It doesn't matter how or what you assume, you can always try to test things. If your assumptions are right or wrong will be shown by the test. :)
-
Maybe were you confused by the static keyword ? If that's the case I can't emphasis enough how important it is to read a good book on C++ before starting doing some fancy stuff.
-
I think what hurt me here is the assumption that Keyboard was handled similarly to an event. I looked into this last night, and I guess I either didn't look in the right place, or I missed the static keyword (dunno how). I know what static means, lol.
-
I think what hurt me here is the assumption that Keyboard was handled similarly to an event
Isn't the tutorial clear enough about the difference between these two APIs?