Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - JNoid75

Pages: [1]
1
Graphics / Text returns incorrect global bounds
« on: April 23, 2012, 10:53:42 pm »
Calling getGlobalBounds() on a sf::Text object gives some weird results. This has been causing trouble for me as it makes positioning text a real pain. I apologize if this has been answered somewhere else (or if it's just me being a noob, I'm kind of new to SFML), I looked and didn't see anything.


Code I'm using:

    sf::Text text("||| Bounds don't line up with the text |||", font, 24);
    text.setOrigin(text.getGlobalBounds().width/2, text.getGlobalBounds().height/2);
    text.setPosition(window->getSize().x/2, window->getSize().y/2);
    text.setColor(sf::Color::Green);
 
    sf::RectangleShape R;
    R.setSize(sf::Vector2f(text.getGlobalBounds().width, text.getGlobalBounds().height));
    R.setOrigin(R.getGlobalBounds().width/2, text.getGlobalBounds().height/2);
    R.setOutlineThickness(1);
    R.setOutlineColor(sf::Color::Black);
    R.setFillColor(sf::Color::Red);
    R.setPosition(window->getSize().x/2, window->getSize().y/2);
 

Pages: [1]
anything