Hello everybody,
I am a begginer with SFML and I want to get some text from a file and render it on the screen. I did this. With SFML is simple and intuitive.
It is something like this:
........
std::ifstream file("Data/chapter.txt");
std::string chapter[11];
if(file.is_open())
{
for(int i = 0; i < 10; i++)
{
std::getline(file, chapter[i]);
}
file.close();
}
sf::Font font;
font.loadFromFile("Data/Font/comic.ttf");
sf::Text Chapter[11];
for(int i = 0; i < 10; i++)
{
Domenii[i].setFont(font);
Domenii[i].setColor(sf::Color::Black);
Domenii[i].setString(chapter[i]);
Domenii[i].setCharacterSize(26);
}
..... and then window.draw(Chapter[0]);
I have no problem when txt files that look like this:[attachment=19956:Capture.PNG]
But when lines are longer, like this:[attachment=19957:Capture.PNG] and I want to print the text, it goes out of screen.
What I need to know is that if is a way you can make a new line to format the text that it won't print outside the screen boundaries?.
I hope you guys can understand what I wrote.. I am still learning english.
Thank you.