I'm having trouble with a function that passes Event.MouseButton.Button as an argument:
Declaration:
void HandleMouseClick(Button click, int x, int y);
Called in the main program loop:
if(Event.Type == sf::Event::MouseButtonPressed)
HandleMouseClick(Event.MouseButton.Button, Event.MouseMove.X, Event.MouseMove.Y);
Definition:
void HandleMouseClick(Button button, int x, int y)
{
if(button == Left && g_Mode == MAINMENU)
{
if(x >= 264 && x < 800 && y >= 300 && y < 325)
{
g_Mode = LOBBY;
}
else if(x >= 264 && x < 800 && y >= 326 && y < 367)
{
g_Mode = OPTIONS;
}
else if(x >= 264 && x < 800 && y >= 368 && y < 409)
{
ExitGame = true; // calls MainWindow.Close() to end the program
}
}
}
The objective of this code is to make it so that when the mouse is over a certain menu item (the x and y values), and the left mouse button is clicked (button == Left), it will execute the correct action.
However, I get the following errors on the definition:
Error: Variable or field HandleMouseClick declared void
error: `Button' not declared in this scope
error: expected primary-expression before "int"
error: expected primary-expression before "int"
error: initializer expression list treated as compound expression
etc. etc.
I'm guessing I used "Button" incorrectly. Can someone point out what I did wrong here?