hey there,
as the title says, the keyReleased doesnt respond:
extern sf::RenderWindow* window;
#define SPACE sf::Keyboard::Key::Space
void gameplay::pause()
{
//pausing by space;
sf::Event event;
while (window->pollEvent(event)) {
if (event.type == sf::Event::KeyReleased) {
if (event.key.code == SPACE) {
sf::Clock clock;
while (clock.getElapsedTime().asSeconds() <= 1.5f) {}
bool goon{ true };
while (goon) {
while (window->pollEvent(event)) {
if (event.type == sf::Event::KeyReleased) {
if (event.key.code == SPACE) {
goon = false;
}
}
}
}
}
}
}
}
Key events have a delay already so you don't need to wait to prevent multiple events from a single click (if that is why you are using the delay). You can simply catch a sf::Event::KeyReleased and toggle your pause variable since the way you are doing it ANY events during pause get no answer.
Regardless of this the main point was: is this the only place you are looping window events ? If not you are loosing them somewhere else.
bool paused = false;
sf::Event event;
while (window->pollEvent(event))
{
if (event.type == sf::Event::KeyReleased)
{
if (event.key.code == SPACE)
{
paused = ! paused;
}
}
}
This code will work if this is the only place you loop window events. How exactly you would then use the "paused" variable is actually another matter.