http://en.sfml-dev.org/forums/index.php?topic=5559.0Also, a few notes about the code:
if (mousepos.x >= xcord && mousepos.x < xplus50 && mousepos.y >= ycord && mousepos.y < yplus20 && sf::Mouse::isButtonPressed(sf::Mouse::Left))
I would change this to a sf::Rect<int>, and this if statement would be a lot cleaner, thus becoming:
if(rect.contains( mousepos.x, mousepos.y ) && sf::Mouse::isButtonPressed(sf::Mouse::Left))
void buttonSlider(int xcord, int ycord, sf::RenderWindow& windowName)
The variable named "windowName" doesn't make sense here. Also, with the coordinates, passing a sf::Vector<int> would be easier to read in my opinion.
windowName.draw(bbox);
windowName.draw(bslider);
if (mousepos.x >= xcord && mousepos.x < xplus50 && mousepos.y >= ycord && mousepos.y < yplus20 && sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if (active == false && sf::Mouse::isButtonPressed(sf::Mouse::Left)){
bslider.move(25, 0);
active = true;
}
if (active == true && sf::Mouse::isButtonPressed(sf::Mouse::Left)){
bslider.move(-25, 0);
active = false;
}
}
Indentation could use a little work, but it seems like a copy-paste error. Any particular reason that you are moving a box
after you draw it, and then it gets destroyed? If you don't understand what I mean, read up about
RAII.
it returns either true or false to a Boolean
void buttonSlider(int xcord, int ycord, sf::RenderWindow& windowName)
Don't contradict yourself.
Please bear in mind I don't have a lot of experience with functions
Learn about functions, then. This function that you posted doesn't do anything like you think it should. If it still doesn't make sense to you, learn about scopes. This question is nothing (aside from using the library) to do with SFML, and there are better forums to ask these kinds of question to.