So I have this 'Label' class based on sf::Text and I'm trying to make it so that Label.getPosition() returns the top-left coordinates of the text (as you would do by adding the .top and .left offset). However my code sets the new origin to (0, -25) thus making it invisible, how can I fix this?
Label constructor:Label::Label(string text) {
// Object constructor, black text 25 pixel high.
m_label.setFont(default_font);
m_label.setCharacterSize(25);
m_label.setFillColor(Color::Black);
m_label.setString(text);
m_label.setOrigin(m_label.getLocalBounds().width - m_label.getLocalBounds().left, m_label.getLocalBounds().height - m_label.getLocalBounds().top);
}
Pseudo code for main loop:Label text("Hello World!");
int main() {
// Basic window function and event handling here
text.setPosition(10, 10);
window.clear();
window.draw(text);
window.display();
}
The outcome is just an empty window.
[S O L U T I O N]
Looks like eXpl0it3r was TOTALLY correct, the font must be declared locally. You are an experienced dev!
Thanks for the help.