An Illustrated Guide to the Display Text Behaviour

ArmellineArmelline Posts: 4,360
edited March 2015 in Community Tutorials

Every so often questions pop up regarding the Display Text behaviour and the expression editor. I thought I'd take a few minutes to write up a brief guide to some little tips and tricks that might help you use it. Some of these tips are pretty obscure, but you never know who they might help!

Some of the advice in this guide will only apply to Mac OS X, but most should be helpful to all GameSalad users!

★ Section 1: Using GameSalad’s Display Text Behaviour ★

This section will deal with the Display Text Behaviour, and the options you'll see on it.

♦︎ Text Colour ♦︎

The default text colour for the Display Text behaviour is white. The default colour for a new actor is white. This can cause some confusion - new users will sometimes add a display text and wonder why it’s not showing up. It probably is, the text is just the same colour as the actor! Hopefully we’ll get a default text colour of black soon to avoid this problem.

You cannot change the text colour at run-time, so the text will only ever display in the colour you define in the Display Text behaviour.

♦︎ Wrap Inside Actor ♦︎

You have two options for how the text you display is formatted. The default behaviour is to display the text centred, both vertically and horizontally. The potential drawback of using this method is that if the text displays larger than the actor, it will overrun the edges of the actor. This can be very helpful, though!

When the “Wrap Inside Actor” checkbox is ticked, the actor’s dimensions define the placement of the text. The text will be displayed within the boundaries of the actor. It will also default to starting at the top of the actor.

"Wrap Inside Actor" unchecked:

"Wrap Inside Actor" checked:

♦︎ Text Alignment ♦︎

You can control the horizontal alignment of the text by using the three alignment options. These will be familiar to anyone who has used any word processing software in the past. The three options are left-aligned, centre-aligned and right-aligned.

♦︎ Text Position ♦︎

You can specify the position of the text using X and Y co-ordinates. I’m not going to go into this in any detail as this functionality is present in many places in GameSalad and hopefully you’ll be familiar with it. Decimal places are accepted.

One thing to remember is that the alignment of the text does affect how it is displayed. There’s a lot of things to consider here - more combinations than are reasonable to spell out in this tutorial - but have a play around with it and see!

When displaying text, it can be displayed “Relative to: actor” or “Relative to: scene”.

Text displayed “Relative to: actor” will be displayed as the given co-ordinates relative the actor. If you move the actor, the text will move with it. Text displayed “Relative to: scene” will be displayed at the given co-ordinates relative to the scene as a whole. If you move the actor, the text will not move as it’s being displayed at fixed co-ordinates.

"Relative to: actor":

"Relative to: scene":

♦︎ Text Direction ♦︎

You can use the Direction to specify the rotation of the text, relative to the actor or scene. Any angle between 0 and 360 is accepted. Decimal places can be used.

Just like with the text position you can specify if you want the text to be angled relative to the actor or the scene. When angled relative to the actor, if the actor rotates the text will rotate with it. When angled relative to the scene, the text will remain at the same static rotation even if the actor is rotating.

"Relative to: actor":

"Relative to: scene":

♦︎ Text Font ♦︎

GameSalad has a selection of fonts to choose from. They are demonstrated in the image below. These are the only fonts available to use - new ones cannot be added. We’re hoping for fully custom fonts to be added in the not too distant future!

♦︎ Text Size ♦︎

You can display text sized between 0 and 100.

★ Section 2: Typing Directly Into The Text Box ★

If you just want to display some text and don't need it to ever change, you may want to type your text directly into the provided box. This is the fastest and easiest way of defining text to display. However, there are still a few things worth knowing!

♦︎ New Lines ♦︎

When typing directly into the text box (i.e. not opening the expression editor), you can add new lines by pressing ALT+RETURN. You'll only be able to see one line of text at a time, but you can move the blinking text cursor up and down to see the extra lines.

This will display the following in-game:

♦︎ Tabs ♦︎

You can add tabs by pressing ALT+TAB. It will look like you've just inputted a space, but when seen in-game, the gap will be a little bigger than a standard space. In the image below, the top text has a space, the bottom text has a tab.

♦︎ Special Characters ♦︎

You can input a large number of special characters into your text strings. To access the special characters, look in the Edit menu.

Note that the colour assigned to the text in the display text will be assigned to the characters.

★ Section 3: Using The Expression Editor ★

If you open the expression editor and enter your text it becomes a little more confusing, but you get access to more functionality. You can do things like displaying attributes, or performing maths functions. There’s a lot of power available if you know how to use it!

♦︎ Using Quotations ♦︎

In order to tell GameSalad that what you’re writing in the expression editor is text, rather than a function of some kind, you need to enclose it in either single ( ‘ ) or double ( “ ) quotation marks.

♦︎ Spaces ♦︎

You may have noticed that you can’t press the space bar to input a space when typing in the expression editor. In order to input a space, you need to press ALT-SPACE. This will allow you to add spaces to your text (which will of course be inside quotation marks!)

♦︎ Line Breaks ♦︎

If you want to include a line break inside the expression editor, you need to use the escape sequence \n

This will place a line break into the text (though I got the colour wrong when taking the previous picture):

♦︎ Tab ♦︎

In order to input a tab while using the expression editor, you need to use the escape sequence \t

The result of this will be:

♦︎ Escaping ♦︎

You may be wondering how you display the text \n in the expression editor. For example, if you’re displaying text explaining the use of the \n escape sequence! Any time you want to display a character the expression editor would read as something other than text, you need to escape it using an additional .

The following characters are some of the characters that need escaping if you want to use them in your text. along with the escape sequence you need to use to display them:

\ = \\
" = \"
' = \'
[ = \[
] = \]

♦︎ Double Square Brackets ♦︎

One thing I’ve never seen discussed is the use of double square brackets - [[ ]]

These are deceptively powerful and give you more freedom of control within the expression editor. Anything you put in the expression editor between double square brackets will be displayed exactly as it is - no escaping needed. This includes line breaks with ALT-RETURN and tabs with ALT-TAB.

Try copying and pasting the following text into the expression editor:

text “needs” formatting
in ways \n \t you
find [easier] doing in

The result of the above should be this:

One thing to note is that you need to type the text using ALT-SPACE to input a space - any normal spaces will still be stripped out!

You can also combine these double backers with attributes using the methods described below!

♦︎ Displaying Attributes ♦︎

One of the brilliant things about the Display Text behaviour and the expression editor is that it enables you to display attributes. To display an attribute, all you need to do is select it using the expression editor.

If the attribute changes, this change will be reflected in the text displayed.

♦︎ Concatenation ♦︎

Another powerful function of the expression editor is the ability to concatenate (combine) two or more strings or numbers. You can combine text, numbers, attributes. One thing you can’t combine, though, is booleans.

In order to concatenate two things, use two periods - ..

Some examples of concatenations and their results are below.

This expression:

Returns this result:

And this expression:

Returns this result:

♦︎ String/number coercion ♦︎

GameSalad lets you use use strings that are composed of digits and numbers interchangeably. This means if you have, for example, a number that is stored in an attribute, you can add a number stored in a string to it.

This works both ways - if you store a number in a text attribute, you can still perform maths functions on it.

That’s it for now! There are of course a number of useful string functions included in GameSalad, and I’ll hopefully update this guide at some point in the future to include them. For today, though, I’m just focusing on how to display text and some of the little features of the expression editor found in the Display Text Behaviour!



  • A_ConstantinA_Constantin EnglandPosts: 79

    Fantastic post! Please do this for other behaviours!

  • jamie_cjamie_c Posts: 5,276

    @Armelline, killer post and great info! I'm sure this will come in handy for new users for a long time to come.

  • HopscotchHopscotch Posts: 2,553

    Nice @Armelline, a valuable reference post!

  • ArmellineArmelline Posts: 4,360

    Thanks for the feedback!

    I do recommend experienced users take a careful look too - some of the stuff like the double brackets ( [[ ]] ) aren't commonly known!

  • floatingwoofloatingwoo Los Angeles, Calif.Posts: 393

    Sweet!!! Thanks

  • SocksSocks London, UK.Posts: 12,457

    Probably the most comprehensive post I've ever seen on the forums, fantastic post !! Someone give this man a job rewriting the GS manual !!

  • Cool, some very useful information for all.

  • zweg25zweg25 Posts: 737

    Wow very informative. I learned some new things on there just by scanning it!


  • jonmulcahyjonmulcahy Posts: 10,365

    great job!

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,786

    Excellent and insightful post! Thanks for sharing!

  • Thunder_ChildThunder_Child Posts: 2,331

    Wow! Finally us noobs can learn something. Yay !

    Thanks this is great !

  • BigDaveBigDave Posts: 2,127
    edited March 2015

    damnnnnn! wow good job man.
    i really wish it would be possible to change the text color in run time ://

    i did not knew about the emoticons at all..after 1.5 years of doing it full time

  • tatiangtatiang Posts: 10,722

    Awesome, awesome, awesome, awesome, awesome. @Braydon_SFX Give the man some kind of badge! ;)


  • ArmellineArmelline Posts: 4,360

    Thanks guys for the kind words and thanks for the sticky! I have another few planned when I find the time!

  • Very insightful info in there. Nice job!

  • stragstrag Posts: 450

    Fantastic...thank you :)

  • bufteabuftea Posts: 43

    examples - that's the secret! in a clear step by step manner; thanks! Now (and I hope I'm not too audacious) Spawn, Timer and probably Animate should follow

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,786

    @tatiang said:
    Braydon_SFX Give the man some kind of badge! ;)


    Done. :D

  • gamestudentgamestudent Posts: 503


  • mc99093mc99093 Posts: 133

    Great post!

  • SLOCM3ZSLOCM3Z Posts: 791

    Cool! This is a very good demonstration! Thanks ")

  • ArmellineArmelline Posts: 4,360

    Thanks guys!

    @buftea said:
    examples - that's the secret! in a clear step by step manner; thanks! Now (and I hope I'm not too audacious) Spawn, Timer and probably Animate should follow

    Your wish is my command!

    I'll probably tackle the Timer behaviour at some point but I currently have no plans to do one for Animate.

  • bufteabuftea Posts: 43

    thank you, I gave the thumbs up on that thread. The Timer and Animate have workarounds as I've found out. The Animate workaround is quite simple to use. But the Timer workaround ... that is something else ...

    So if you ever think about tackling the Timer, a parallel between the two ways to count the time would help me understand things better

    I hope to do one of this myself in the future.

  • ArmellineArmelline Posts: 4,360

    I definitely have timers planned for next, and will definitely be looking at some alternative timer methods too!

  • FrantoFranto Posts: 778

    Great guide! I wanted to know if using display text for enemy HP is very resource intensive and potentially causes slow down if say there are 10 enemies on screen with display text active?

  • ArmellineArmelline Posts: 4,360
    edited March 2015

    @Franto said:
    Great guide! I wanted to know if using display text for enemy HP is very resource intensive and potentially causes slow down if say there are 10 enemies on screen with display text active?

    Shouldn't be a problem unless your game is extremely busy. But if that's the case, a few display texts aren't going to be your main problem :D

  • ogreofwartogreofwart Hello Everybody on the Gamesalad Planet. I come in peace, warts'n'all!!! Lancashire UKPosts: 281

    Brilliant as always, give that man a very shiny medal and a pat on the back.
    Keeping this marked for future reference and I recommend others do so too :)

  • RThurmanRThurman Posts: 2,688

    @Armelline -- this is very handy! Thanks for making this guide and sharing it with the community!

  • Hi guys, I'm new to GS. I'm making a trivia game and I've used a lot of display text behavior in my prototype. My template is for iPhone 5 Portrait and I noticed the texts gets blurry as I switch my template to larger screens, let's say the 6 Plus. Is this really the case? Or will the text resolution increase by itself when I do adhoc.

  • Great post, very detail. I would like to know if its possible to put a Text along with an Attribute.

    For example I have an integer attribute called Rank, and so I want to write "Your Rank:" infront of the Rank attribute. I tried:

    Your Rank: (game.Rank)
    "Your Rank:" game.Rank
    "Your Rank:" + game.Rank
    ...and several more trials but nothing works.

    I think it should be possible, right?

Sign In or Register to comment.