Adding text and a variable to a text behaviour.

etheridgeetheridge Member Posts: 12
edited November -1 in Working with GS (Mac)
Hi again folks!
Okay it's time for me ti ask yet another question...

How can I add text and a var to a text behaviour? Basically I'm trying to dump on the screen "Score: + VAR".

I know it's going to be something really simple but I am actually brain dead tonight!
Argh, I'm actually a developer by trade and do this for a hobby, so asking this is grating me :-)

Good job you folks are all uber coolio.

Jase.

Comments

  • reddotincreddotinc Member Posts: 653
    Type in the expression editor "Score: "..game.score

    or whatever your attribute is :P the ".." is required.

    alt+space for a space I think :/
  • ancchancch Member, PRO Posts: 103
    Really helpful. Thanks!!
  • netdzynrnetdzynr Member Posts: 296
    Here's a question about the Display Text behavior -- does using this place as much burden on the processor as a Timer or Constrain behavior? When I use Display Text to display variable values (debugging), the text constantly updates itself without any need to "refresh" it, which makes me think that it's operating much like a Constrain behavior. Anyone know if this is or is not the case?
  • AfterBurnettAfterBurnett Member Posts: 3,474
    I just get "invalid expression" with the above method :(
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to choose all the attributes from the drop down menu - you cannot type them in.

    And the text needs to be in quotes.

    So:

    Display Text: "Hi, my name is "..game.myName..". It is nice to meet you."
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Yeah, I did that. Hmmm... I'll give it another go when I get home. GS has been playing up for me... maybe time for a fresh install!
  • etheridgeetheridge Member Posts: 12
    Hi.
    Cool that worked perfectly!

    One other small question, do you know how to put spaces in? For example "Score:"..game.Blah

    But after the Score: it won't let me put a space in?

    Jase.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You have to type Option-Space to add spaces and Option-Return to add line breaks.

    However, I am not sure if those work on the device as well. You need to test it.

    I'm sure the line breaks are messed up as the text is still centered.

    If you want to be totally safe, I would make a global text attribute called 'space'. And make it a single space character: " ". (without the quotes)

    And use it like this:

    Display Text: "Score:"..game.space..game.score

    Using .. to add text and variables together is called concatenation.
    A much more powerful use of this technique is to use it for setting the Image of an actor, like this:

    Change Attribute: self.Image To: "image_"..self.myImage..".png"

    Hopefully they will add this ability throughout the engine. However, it can cause issues if you try and access something that isn't there...
  • etheridgeetheridge Member Posts: 12
    As normal guys your help is amazing, and appreciated!!

    Has anyone else been having issues with text alignment? I'm click the left, centre and right and that text is staying in the same place. Doh!

    Jase.
Sign In or Register to comment.