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

Author Topic: Array of texts with indentations  (Read 91 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Array of texts with indentations
« on: June 18, 2020, 02:02:41 pm »
Hello! I'm just starting out in SFML and I need your help. I'm trying to display a conversation between two people but the texts will have different indentations, for example:

          Hello, how are you?
                                           Good thanks! you?

Something like that, any ideas how I can do that?


  • Hero Member
  • *****
  • Posts: 3017
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Array of texts with indentations
« Reply #1 on: June 18, 2020, 06:22:03 pm »
It each line is its own text object, simply change its horizontal position.
If you need it "right-aligned", you'll need to make some calculations; simplest option is to just move the origin to the right-hand side and then position the text on the right-edge.

If everything is one text object, you'll need to pad the beginning of certain lines with spaces (or tabs). This is less accurate since spaces are fixed but if it's just indentation you're after, this could work.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter