SFML community forums

Help => Graphics => Topic started by: HammaJamma on June 10, 2014, 03:52:00 am

Title: strange behavior moving around a text object
Post by: HammaJamma on June 10, 2014, 03:52:00 am
Hello.
I created a couple functions that process text input and display it to the screen using sf::text.
When the the bottom of the sf::Text object reaches a desired point it will begin scrolling the text upward to make sure it does not go below that point and if you begin removing text it will move the sf::Text object back down.
the problem I have is when the text begins scrolling down, it will jump up to a random point for probably a single frame.
any ideas why this is happening?
also, I'm looking for general feed back concerning both functions. Is there anyway I can improve on any part of this code?
(click to show/hide)
Title: Re: strange behavior moving around a text object
Post by: HammaJamma on June 11, 2014, 12:29:13 am
I figured out a much simpler way to write the positionText function and it simultaneously fixed the buggy behavior :)
here's the function, in case anyone else is interested.
void positionText(sf::Text &text, sf::Vector2f dimensions, sf::Vector2f position)
{
        if(text.getLocalBounds().height > dimensions.y)
        {
        text.setPosition(position.x, position.y + (dimensions.y - text.getLocalBounds().height));
        }
};