So far I have this:
sf::Text text2("One moment I'm going out with this cute girl and the next, I get stabbed in the chest with", font, 50); //77 Characters
text2.setPosition(100,790);
sf::Text text3("a spear. What to do now...just wait? Hmm, I wish I had more time to at least say goodbye", font, 50); //77 Characters
text3.setPosition(100,860);
using file stream, is it possible to simplify it down to something where it would read a line at a time and once it has read 77 characters, it would move on and fill text3, then text4, etc?
What you want is called wordwrapping.
But here some code I made for you, that hopefully may help you get going
#include <fstream>
#include <sstream>
#include <list>
#include <SFML\Graphics\Text.hpp>
#include <SFML\Graphics\Rect.hpp>
int main()
{
std::string line;
std::ifstream file;
std::list<sf::Text> textList;
sf::Text text("", font, 50); //Load your font and replace 'font'
file.open("text.txt"); //Set your path here
if(file.is_open())
{
while(std::getline(file, line))
{
//Getting every line of the .txt file and putting it in the 'line' string
text.setString(line);
textList.push_back(text);
}
}
float i = 0;
for(std::list<sf::Text>::iterator it = textList.begin(); it != textList.end(); ++it)
{
sf::Text& text = *it;
sf::FloatRect boundings = text.getLocalBounds();
text.setPosition(0.f, i * (boundings.height + 5));
++i;
//draw or something here
}
}