Hi
First, I loved SFML.
Thank you for that !
Can you tell me why this doesnt work ?
// ... before game loop
sf::View cameraView(sf::FloatRect(0, 0, GamePreferences::WINDOW_RESOLUTION_WIDTH, GamePreferences::WINDOW_RESOLUTION_HEIGHT));
// ... inside game loop
window.setView(cameraView);
handleInputEvents(&window);
// ... end of game loop method
// method handleInputEvents
void Director::handleInputEvents(sf::RenderWindow *window) {
sf::Event event{};
sf::View view = window->getView();
while (window->pollEvent(event))
{
if (event.type == sf::Event::MouseWheelScrolled) {
if (event.mouseWheelScroll.delta == 1)
view->zoom(0.95f);
else if (event.mouseWheelScroll.delta == -1)
view->zoom(1.05f);
}
}
}
The zoom does not change.
However, if I provide cameraView to handleInputEvents as a parameter, it does work.
Also if I copy the handleInputEvents to the game loop (instead of using a method).
What am I doing wrong here ?