Hey all,
I just recently written a class for my sprites to display in my loop but it won't display, i don't get an error of any kind, and it doesn't fail to load the image so I'm lost to why it is not displaying them.
This is how i create the buttons in
main():
//there are 2 buttons one for normal & one for mouse hover
sf::Sprite button;
sf::Texture button_t;
sf::Sprite button_on;
sf::Texture button_on_t;
load(button_t,button_on,theme["Button"]);
load(button_on_t,button_on,theme["Button_On"]);
int width = button.getLocalBounds().width;
int height = button.getLocalBounds().height;
Button btn_quit(350,450,width,height,"Quit Game");
In my
loop i display it like so:
btn_quit.RenderBttn(window,mouseX,mouseY,button,button_on);
And this is the
relevant class which deals with it all:
Button::Button(int x, int y, int w, int h, std::string cap)
{
m_y = y;
m_x = (x / 2) - ( w / 2 );
m_w = w;
m_h = h;
caption = cap;
}
bool Button::IsIn( int mouseX, int mouseY )
{
if (((mouseX > m_x) && (mouseX < m_x + m_w))
&& ((mouseY > m_y) && (mouseY < m_y + m_h ) ) ) {
return true;
} else {
return false;
}
}
void Button::RenderBttn(sf::RenderWindow& destination,int &mouseX, int &mouseY,sf::Sprite& button, sf::Sprite& button_on)
{
sf::Sprite result;
result = IsIn(mouseX,mouseY) ? button_on : button;
result.setPosition( m_x , m_y );
destination.draw(result);
}
Any idea why it won't display? Even though i get no errors and the image is being loaded?