Text Alignment - Top/Middle/Bottom - how to???

fmakawafmakawa Member Posts: 565
edited October 2016 in Working with GS (PC)

Hi folks,
I was wondering if there is a way to align text so that it starts at the top of an actor or bottom much like left, center and right alignment options? I current have actor of some size and the content of it changes. The current center alignment as default proves problematic as if the actor has little text I have text only showing in the middle quite far away from the headings. Using the positioning setting only shifts the text but doesn't sort out alignment.Any ideas?

Comments

  • fmakawafmakawa Member Posts: 565

    bump

  • ArmellineArmelline Member, PRO Posts: 5,354

    Set the Y position to actor's height/2+-text size.

  • fmakawafmakawa Member Posts: 565

    @Armelline said:
    Set the Y position to actor's height/2+-text size.

    text size being text length?

  • zweg25zweg25 Member Posts: 738

    I think he means text size as font point size

  • fmakawafmakawa Member Posts: 565

    @zweg25 said:
    I think he means text size as font point size

    Okay but that keeps the text relatively center aligned. I primarily want it at the top. I need an expression sonce text length varies according to the levels. So far all I've come up with has the length all over the place. Essentially I have a box of uniform size (9 boxes actually). The box shows text that has been generated in the level. Depending on the level the content of that boxes changes. Now if I change the vertical position I'm hitting a snag that the position since not taking proper account of text length ends up pushing the text too low or too high). I think I have to work with some sort of function to set upper and lower limits and then calculate the location within that.

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited November 2016

    Please illustrate what you mean, as what you describe there doesn't sound like top or bottom alignment. And text length should only affect bottom alignment - top alignment you can just use "wrap inside actor." Sounds likely that there will be no easy way to achieve what you want, though

  • fmakawafmakawa Member Posts: 565

    @Armelline
    This is what I am trying to do. The text is rendered at the top of my actor going down.

    This is how it is being rendered- from the center. Text wrap is already there and simply inputting a value into the vertical axis results in it shifting the whole text up and eventually beyond the confines of the actor.

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited November 2016

    If you don't know the number of lines of text, you're not going to be able to easily do that, then. If you know the number of lines and the font size, though, it's easy enough. If you're pre-wrapping your text you can even easily calculate the number of lines.

    Not sure exactly when GS started putting wrapped text in the centre, though. Maybe I imagined that it used to be top aligned. Ignore that suggestion!

  • fmakawafmakawa Member Posts: 565

    @Armelline said:
    If you don't know the number of lines of text, you're not going to be able to easily do that, then. If you know the number of lines and the font size, though, it's easy enough. If you're pre-wrapping your text you can even easily calculate the number of lines.

    Not sure exactly when GS started putting wrapped text in the centre, though. Maybe I imagined that it used to be top aligned. Ignore that suggestion!

    Does the text length function also count spaces in a text? If so then the number of lines can be calculated since I do know how many characters form each line and by dividing the total length with that character length then I would be able to get the number of lines. Font is 30 if I recall.

  • ArmellineArmelline Member, PRO Posts: 5,354

    @fmakawa said:
    Does the text length function also count spaces in a text? If so then the number of lines can be calculated since I do know how many characters form each line and by dividing the total length with that character length then I would be able to get the number of lines. Font is 30 if I recall.

    It should count spaces, yes.

  • fmakawafmakawa Member Posts: 565

    @Armelline said:

    It should count spaces, yes.

    Then how do use the number of lines and font size to align it? (#line*fontsize)/2 ?

  • ArmellineArmelline Member, PRO Posts: 5,354

    This is actually going to be a lot tricker than I'd thought due to how GameSalad handles line spacing.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    Yeah they kind of messed this up when custom fonts came around =(

    Follow us: Twitter - Website

  • ArmellineArmelline Member, PRO Posts: 5,354
  • fmakawafmakawa Member Posts: 565

    @Armelline wicked!! Thanks

  • fmakawafmakawa Member Posts: 565

    @Armelline hahaha, love the commentary btw!! Wasn't using a table since the text is being stored in game attributes so I need to tweak that a little after I've fully understood what you did (in particular the purpose of the mod function when clicked. I would have thought all you would do is add 1- funny as I was typing that it clicked. It was to allow infinite clicks and the data would always be available instead of going beyond the number of rows! brilliant! - I love the things I learn of your work! Just brilliant!). As for the issues regarding wrapping, I'm hoping that should be an issue since each actor will have words of specific length, 4 letter words together, 5 letters together etc. Means If I tweak each actor I should get an optimal display perhaps?

  • ArmellineArmelline Member, PRO Posts: 5,354

    @fmakawa said:
    @Armelline hahaha, love the commentary btw!! Wasn't using a table since the text is being stored in game attributes so I need to tweak that a little after I've fully understood what you did (in particular the purpose of the mod function when clicked. I would have thought all you would do is add 1- funny as I was typing that it clicked. It was to allow infinite clicks and the data would always be available instead of going beyond the number of rows! brilliant! - I love the things I learn of your work! Just brilliant!). As for the issues regarding wrapping, I'm hoping that should be an issue since each actor will have words of specific length, 4 letter words together, 5 letters together etc. Means If I tweak each actor I should get an optimal display perhaps?

    The mod function when clicked is simply to cycle through the rows of the table. You probably don't need to adapt that, particularly if you're using attribute to store the text.

    With a bit of tweaking you should be able to get optimal display, sure! It'll not likely be simply a case of copying what I did, though, adaption and adjustment will be necessary.

  • fmakawafmakawa Member Posts: 565
    edited November 2016

    @Armelline when you said it would need tweaking you weren't far off the mark. I'm seeing an odd behaviour though and its proven problematic.

    Those 2 actors have the same code. The only difference is the what they are displaying yet there is a massive difference in alignment. This is true for all the display actors which these fluctuations. The example I've given is the most drastic and the rest are much smaller. I even put a timer for the display just in case it was because the content of the display hadn't been fully compiled yet when the calculations were made and there was no difference. Any idea what might be causing this?

    Plus when I change the puzzle and the content changes the alignment changes too and it can be drastic like below

  • ArmellineArmelline Member, PRO Posts: 5,354

    The code will need to be adjusted. Did you change the letters per line attribute? The demo is in no way intended to be usable with any length of text or font size - it's just a starting point, to edit until it works for your needs. At the very least you'll need to change the font size and letters per line parts of the equation.

  • fmakawafmakawa Member Posts: 565

    Yes I did. Those actors are the same size so the number of letters per line is the same. font is 20 so I changed that too. The actual length of the text is what is changing per actor but the formula is supposed to take that into account. Unless there is something I am missing somewhere.

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited November 2016

    @fmakawa said:
    Yes I did. Those actors are the same size so the number of letters per line is the same. font is 20 so I changed that too. The actual length of the text is what is changing per actor but the formula is supposed to take that into account. Unless there is something I am missing somewhere.

    Sorry, this template wasn't meant to or expected to work universally. It was only ever intended to show a general method you can use, adjusting and adapting it for your text needs. It'll just be a matter of experimenting until you get it good enough for the size of text and font you're using. It's also not going to work nearly as well with a variable width font, as characters per line become less reliable.

  • fmakawafmakawa Member Posts: 565

    Thanks. Will keep working at it till it works. Might end up just sticking to the center align if I cant find a consistent display. Or perhaps try the varying the height of the box itself depending on the text lenght and have its position constrained whilst taking that it into account. I'll see.

Sign In or Register to comment.