I don't know whether any two of us have got the same problem. :roll: But after having played around with my code I have found at least a solution for me. Maybe it helps one of you ...
Following function does not work how I want it to (it always returns false):
bool IsADown()
{
const sf::Input& input = myWindow->GetInput(); // myWindow is a pointer to my RenderWindow
if( input.IsKeyDown(sf::Key::A) )
{
return true; // never happens
}
return false;
}
Note: The Input instance always seems to return default values (all keys are released, mouse coordinates are 0/0, etc.)
If I expand my function with some (in my eyes needless) code, it works flawlessly:
bool IsADown()
{
sf::Event event;
myWindow->GetEvent(event); // this seems to make the difference
const sf::Input& input = myWindow->GetInput();
if( input.IsKeyDown(sf::Key::A) )
{
return true; // now it works perfectly
}
return false;
}
Question: Is it really intentional that one has to call GetEvent(event) before accessing the Input instance?
Apart from that: Great library, I love it! Keep up the great work