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

Author Topic: New lines in text  (Read 1402 times)

0 Members and 1 Guest are viewing this topic.

Taco_Farmer

  • Newbie
  • *
  • Posts: 2
    • View Profile
New lines in text
« on: May 08, 2014, 07:52:11 pm »
Okay so I am having a pretty difficult time with using multiple rows of text, the only way I could figure out how to do it was making 26 different sf::texts, one for each line. I am going to have to make quite a few paragraphs in this program that I was making so I need to figure out how to do this easier.

I have seen people reference /n (or \n) but I have no clue how to use it and it isn't in the documentation.

This is what the part of my code where I am setting the string looks like:

if(buttongenerate == 0)
                        {
                                cout << "Generating Deb" << endl;
                                button1t.setString("Debra Morgan");
                                button1t.setPosition(264,224);
                                button1t.setCharacterSize(42);
                        }

What would I have to do to make "Debra Morgan" render as

Debra
Morgan

Thanks in Advance

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New lines in text
« Reply #1 on: May 08, 2014, 08:09:16 pm »
"Debra\nMorgan"

\n is an escape sequence which is interpreted by the compiler as a line break. And sf::Text renders it as expected.
Laurent Gomila - SFML developer

Taco_Farmer

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: New lines in text
« Reply #2 on: May 08, 2014, 08:15:17 pm »
Thanks, I have no idea how I wasn't able to figure that out. It seems so obvious now.

 

anything