Hello guys, I have a problem when I'm trying to draw more than one sf::Text, here's my source code
void GUI::CreateButton(sf::Vector2f position, sf::Vector2f size, sf::String text, sf::Vector2f textPos, sf::Texture buttonIMG, sf::Texture buttonGUIDANCE, sf::Texture buttonCLICK)
{
std::unique_ptr<buttonSettings> rect (new buttonSettings()); // Creating a pointer to struct
font.loadFromFile("D:\\visual studio 2012\\SFML_engine\\Project1\\Release\\Kingthings_Serifique.ttf");
rect->btns.setPosition(position);
rect->buttonIMG = buttonIMG;
rect->buttonGUIDANCE = buttonGUIDANCE;
rect->buttonCLICK = buttonCLICK;
rect->btns.setSize(size);
rect->btnText.setFont(font);
rect->btnText.setCharacterSize(12);
rect->btnText.setString(text);
rect->btnText.setPosition(textPos);
buttons.push_back(std::move(rect));
}
and then, after I've created a button with text, I'm drawing it :
for(unsigned int b = 0; b<buttons.size(); b++) { // draw buttons
_window.draw(buttons[b]->btns);
_window.draw(buttons[b]->btnText);
}
and here, how my struct looks :
typedef struct buttonSettings {
sf::RectangleShape btns;
sf::Text btnText;
sf::Texture buttonIMG;
sf::Texture buttonGUIDANCE;
sf::Texture buttonCLICK;
};
std::vector<std::unique_ptr<ButtonListSettings>> buttonList;
all works fine, except one thing, when I'm creating more than one button with text, it's.. doing some strange things with one text.