I'm trying to make settings state for my game and my mouse scroll detection is not working. I tried to find solution on sfml website, youtube and forums but my code still doesn't want to work
Here's the function I made to move a view:
void Options::CheckEvents()
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) // quit check
this->quit = true;
while(window->pollEvent(this->evnt))
{
if (this->evnt.type == sf::Event::MouseWheelScrolled)
{
std::cout << "[DEBUG]: mouse wheel scrolled\n"; // this one prints, but not always
// (for example 4 prints per 10s of scrolling)
if (evnt.mouseWheelScroll.delta < 0 && view->getCenter().y > WinHeight / 2) // if view center is not too far away
{
std::cout << "[DEBUG]: View moved up\n"; // not printing, even when I remove this ^ check
view->move(sf::Vector2f(0, -view_speed * this->dt));
}
if (evnt.mouseWheelScroll.delta > 0 && view->getCenter().y < WinHeight * 2) // if view center is not too far away
{
std::cout << "[DEBUG]: View moved down\n"; // not printing, even when I remove this ^ check
view->move(sf::Vector2f(0, view_speed * this->dt));
}
}
}
}
Additionally when I move the code out of pollEvent function the view moves only when I move my mouse