I'm using the SFML library and wanted to create a function for events, which worked perfectly fine. until I tried to add a scroll feature using an optional parameter.
my problem simplified
#include <SFML\Graphics.hpp>
int check(sf::RenderWindow&, int& = 0);
int main()
{
sf::RenderWindow win(sf::VideoMode(800,600), "test");
win.setFramerateLimit(60);
int scroll;
while(win.isOpen())
{
check(win);
win.clear();
win.display();
}
}
check(sf::RenderWindow& win, int& scroll)
{
sf::Event event;
while(win.pollEvent(event))
{
if(event.type == sf::Event::Closed)
{
win.close();
}
if(event.type == sf::Event::MouseWheelMoved)
{
scroll += event.mouseWheel.delta*20;
}
}
}
can someone tell me how to do this while still passing scroll as refrence?