Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - romhayh

Pages: [1]
1
System / Re: sf::Event::keyReleased dosent respond
« on: May 25, 2020, 06:14:17 pm »

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.


i have another event loop at the main menu.
 i have implemented what's you said at the last comment and now the code is working just fine -
i had put my pause function in the main's event loop;

2
System / Re: sf::Event::keyReleased dosent respond
« on: May 25, 2020, 03:08:07 pm »
What is this code doing ? You check if the space was released and then if it is you check again if the space is released ?

to pause the game, i am checking if the space bar is released, and if it is, i will wait a bit more than a second and then wait until the user decides to end the pause by pressing space

3
System / sf::Event::keyReleased dosent respond
« on: May 25, 2020, 01:20:15 pm »
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;
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }
       

}

 

Pages: [1]
anything