Hello. Well, it's more like a few questions, not only a problem. I think this is all connected with each-other, so I've posted only one topic.
This is in the main loop of application (60 fps limit)
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::LAlt && paused == 0)
{
cout << "game paused" << endl;
paused = 1;
}
I'm using
bool paused like that:
if (!paused)
{
okno.display();
}
1. Why Event::KeyPressed and Event::KeyReleased are not working with keys other than similar to Alt, Home, End etc?
I've checked it by using:
if (event.type == sf::Event::KeyPressed)
{
cout << event.key.code << endl;
}
It returns key codes, but for letters/digits it does not return anything.
2. I'm trying to pause my game, how, correctly, should I do this? By stopping
Window.display()?
3. How to resume after pausing?
I was trying to use:
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::LAlt) && paused == 1)
{
cout << "game started" << endl;
paused = 0;
}
And here comes another problem - game was starting and stopping few times, till I released LAlt. So, how can I disable "key repetition"?
I guess
Window.setKeyRepeatEnabled(false) works only with events (which imho aren't working correctly here). Additionally I'd have to lock this only when needed (I can't have this locked ex. while im using
W to move up).
I hope you, guys, will understand what do I think about, even with my B2