Center-Aligned Text

Abigayl

  • Posts: 807
Sorry if this is already a suggestion... was feeling too lazy this morning to search.

I'm currently writing the "game over" screens for my game, which is rather annoying since there is no simple "center align" option, so I have to manually determine how to place it in the center. If there was a way to get the text aligned in the center automatically, it would be very useful for titles, etc.
If you need help, please check my tutorials either here or Kongregate (http://www.kongregate.com/accounts/Abigayl) or come over to my stream: http://www.livestream.com/poweredbyflowers

Abigayl

  • Posts: 807
Quick update: I went back to playing around and found that it is possible using coding blocks at least (for anyone else who struggles with this). You can use this coding:
draw [insert text] at x: ([[screen width - width of [insert text] with current font]/2) y: [ ]

Can also do the same with y using heights. The width property can be found in Drawing -> Properties

(It would still be nice to have center-aligned natively included)
If you need help, please check my tutorials either here or Kongregate (http://www.kongregate.com/accounts/Abigayl) or come over to my stream: http://www.livestream.com/poweredbyflowers

coleislazy

  • *
  • Posts: 2607
I agree, it is a pain, but there are block equivalents for that code you posted.

Joe

  • *
  • Posts: 2480
I agree, it is a pain, but there are block equivalents for that code you posted.

I think she's intending for those to be blocks. It only looks like Objective-C because of the square brackets. :P

Abigayl

  • Posts: 807
Joe is correct. I was stating that this methodology is a nice work-around, but it's still a bit annoying, thus a native "center" align would be a nice addition.
If you need help, please check my tutorials either here or Kongregate (http://www.kongregate.com/accounts/Abigayl) or come over to my stream: http://www.livestream.com/poweredbyflowers

coleislazy

  • *
  • Posts: 2607
I think I was still half-asleep when I wrote that. Looking at it now, its obvious that it doesn't even look like code! ;)

neilhanvey

  • Posts: 55
i know this is an old thread and everything but is there a more updated way of doing this? I'm trying to create a button with a behaviour that draws text center aligned on it. it seems like such a regular thing to need to do and i wondered if it was in the newer version of stencyl

LIBERADO

  • *
  • Posts: 2660

i know this is an old thread and everything but is there a more updated way of doing this?
;)  Yes.

Install this useful extension: http://community.stencyl.com/index.php/topic,35352.msg200308.html#msg200308
and use this blocks:
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.