Hey guys!
I'm having a pretty interesting issue. I have a particular even that I use to close the window simply by a key press, but the thing is that it sometimes get's triggered when I don't even press any keys!
This isn't the only event that triggers itself either! I have a different event that saves a screenshot of the program running that also has gone off by itself.
Any thoughts?
The code in question.
if(Event.Key.Code == sf::Key::Escape)
{
App.Close();
}
if (Event.Key.Code == sf::Key::F1)
{
sf::Image Screen = App.Capture();
Screen.SaveToFile("screenshot.jpg");
}
Have you taken a look at the tutorial on events (http://www.sfml-dev.org/tutorials/1.6/window-events.php)? ;)
Although you didn't post all the code I'm going to assume that you don't have the following code infront of the two if statements:
if(Event.Type == sf::Event::KeyPressed)
{
// Your ifs
}
Not checking the event type but accessing Key.Code will lead to undefined behaviour.
Additionally I advice you to use SFML 2.