How do add a line break in a text string?

0 favourites
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Can't seem to find code for a line break. [br] does not work.

    I have a text block with an initial value string that I need to add some line breaks to.

    "Welcome to the Meditation🧘area.👉More^"

    I want to put a line break so it reads like this:

    Welcome to the Meditation🧘area.

    👉More

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • "Welcome to the Meditation🧘area."&newline&"👉More^"

    That's if you record through the event.

    And if you want to manually enter a text field in the editor, then shift+enter = move to the next line.

  • For some reason I've tried that but it does not work.

  • You put everything in as a string, that's not how it works.

    You insert the string you want, it must be in quotes then the concatenation operator & and the newline command.

    "string"&newline&"string"
    
  • Hmm... Still not getting it.

  • You have everything in one variable, the engine sees it all as a string, you need to split it this way or that way.

  • You are using the default browser emiji, for the game it is better to upload your own icons as done in the example.

    editor.construct.net

    This will avoid some problems on different devices. And it is better to upload your own font too.

  • I'm a newbie so, I'm having trouble understanding how to exactly do what you recommend with the way I have it set up. I have a global variable set for the text strings and their advancement when the speech bubble is tapped.

    So, I'm not understanding how to break this up into strings without messing up what I have set up.

    I've tried "text"&newline&"text" and it works great in text elements but not in the global variables.

    Here's an example of my event page.

  • Yes it doesn't work within variables, so you have to split into multiple variables, but that's a hassle.

    I have another suggestion for you, all these dialogs can be stored in an array and the hyphenation is saved there, I made an example for you.

    File *.c3p

  • Dan Blast I see your text contains lots of "^" characters. Do you want to replace them with line breaks? That's what I usually do in my projects:

    MyText Set text to replace(Dialog_Greeting, "^", newline)

    Or you can re-write the contents of the variable:

    Set Dialog_Greeting to replace(Dialog_Greeting, "^", newline)

  • Could I use another character to do that and still use the "^"?

    The "^" is used to advance the text so it does not all show up at once.

  • Of course. You can use any character or your own custom tag, say "{line_break}"

    replace(Dialog_Greeting, "{line_break}", newline)

  • Доп2000 на мою тему не ответил,ждал от тебя ответ как от активного. Этож вопросы быстро решаются,создал несколько тем и ждад пока доп2000 ответит но не фига ((((

  • lightning_ I respond when I know the answer and when I have time. If you need help fast, try Discord or VK group.

  • dop2000

    Still a little confused as to how to paste that in. Can you clarify it for me please?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)