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 - klaus1n3

Pages: [1]
1
General / Check events outside event-loop
« on: February 18, 2016, 11:17:30 pm »
I want to write an input-manager to implement some functions: isKeyReleased etc
My idea was to have a function called update, this function polls for events and "saves" them.
Then later I can call isKeyReleased to check the event:

Update function:
void InputManager::update(sf::RenderWindow& mainWindow)
{
        rWindow = &mainWindow;


        while (rWindow->pollEvent(iEvent))
        {
               
        }
}

and then I want for example check the event type:

bool InputManager::isEventType(sf::Event::EventType eventType)
{
        if (iEvent.type == eventType)
                return true;
        else
                return false;
}


So in my HandleInput function in main:

InputManager::update(mainWindow);

if (InputManager::isEventType(sf::Event::KeyPressed))
        std::cout << "Key Pressed" << std::endl;



But it is not working! I don't know where the problem is.

Is there a possibility to "save" the polled events and check them later?

Pages: [1]
anything