Displaying Text

This forum is currently in read-only mode.
  • What could be the best way to display text for HUD display? currently i try to store my info in a variable (here "AMMO") and retrieve it as a text to tell the player a much bullet i have left.

    Right now i use the TEXT object but i see only a way to display "static" info if i can say so.

    i tried the ADD To Value but i didnt get anything either...

    help please.. i'm lost now

  • Just do Always - Set Text (in the Text object). You can enter any number, variable, anything - the text object will show it.

  • Another tip, put all your HUD stuff on a new layer set above everything else. Then set that layers' scrolling to 0% so it follows the player without repositioning.

  • thanks for the tip Jeswen.

    Ashley:On thing i dont get. When i use Set text. it seem to need to be between quote?

    If i want to display the value of a variable not the name of it, how do i set it?

    because if its quoted it only display the name, unless i miss something.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • http://www.mediafire.com/?0wblyjmvsmg

    I use 2 text files, because I like to keep the numbers by themselves.

  • When i use Set text. it seem to need to be between quote?

    If i want to display the value of a variable not the name of it, how do i set it?

    The (double) quotes mean "Use the exact text I wrote". If you leave out the quotes, you can use any expression you like. With the expression that reads a private variable, that would be:

    Text: Set text to Object.Value('Name_of_the_variable')

    You can use the + operator to combine bits of text with the results of expressions; the only catch is that any expressions that evaluate to numbers have to be converted into the corresponding text strings first. Fortunately, str(Expression) does just that.

    Example:

    Text: Set text to "X is " + str(Sprite.X) + " and Y is " + str(SpriteY) + ", and the variable is " + str(Sprite.Value('Variable'))

  • Delete the quotes and enter a number or variable and it works as you'd expect.

    "X is " + str(Sprite.X) + " and Y is " + str(SpriteY) + ", and the variable is " + str(Sprite.Value('Variable'))

    You can use the & operator to concatenate any variables as text. For example, you could create the same string with:

    "X is " & Sprite.X & " and Y is " &Sprite.Y & ", and the variable is " & Sprite.Value('Variable')

    Looks a little cleaner and is easier to edit that way.

  • thanks all.it answer all my question.'til the next one

    ashley: i get the & stand for the str(sprite.x) to convert float and integer to string?

  • Yes, A & B pretty much means the same as str(A) + str(B).

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