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

Author Topic: strange behavior moving around a text object  (Read 1175 times)

0 Members and 1 Guest are viewing this topic.

HammaJamma

  • Newbie
  • *
  • Posts: 12
    • View Profile
strange behavior moving around a text object
« 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)

HammaJamma

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: strange behavior moving around a text object
« Reply #1 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));
        }
};