Hi Folks,
I have a view that takes up 30% of the window in the y axis, i.e. basically it is a lower view that displays messages/updates as the game progresses.
I have a string that increases with game messages in the game loop, i.e. in a basic form it is as below.
sf::Text text;
string msgStr;
while (true)
{
window.clear();
msgStr += "New game update\n";
text.setString(msgStr);
window.setView(lowerView);
window.draw(text);
window.display();
}
So as you can see the text keeps increasing and it soon goes off the view's screen. So what I want to do is add an if statement to check if the lower y position of the sf::Text entity has gone off-screen. i.e.:-
if (sf::Text.bottom-Y pos > view.y-size)
{
lowerView.move(0,30);
}
However I'm not sure on how to retrieve those two bits of information. So is anyone able to advise on the below 2 questions.
(1) How to get a sf::Text entities bottom(y),left or bottom(y), right position? Basically with each addition of a string with a \n, then the y position of the sf::Text should increase, right? So how can I get this information?
(2) How do I get the view's x and y size, so I can check if the sf::Text's y position has gone off-screen? (in my example I only really need the y size, however I assume I can get the x size as well somehow?)
Many thanks in advance.