Hello!
#include <SFML/system.hpp>
#include <SFML/graphics.hpp>
int main()
{
sf::Font font;
font.loadFromFile("fallout_decayed.ttf");
sf::Text text("EXAMPLE",font, 50 );
text.setPosition( 100, 100 );
text.setColor(sf::Color::Red);
sf::RectangleShape rectangle( sf::Vector2f( text.getGlobalBounds().width, text.getGlobalBounds().height ) );
rectangle.setPosition(100,100);
sf::RenderWindow window( sf::VideoMode(400, 300), "EXAMPLE" );
while( window.isOpen() )
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw( rectangle );
window.draw(text);
window.display();
}
return 0;
}
Why is the text shifted from its position?