Is it possible to change the point where the text is drawn from instead of it being at the top left corner. I want a string to appear centred underneath the screen when the player looks at an object. The length of this string would vary depending on what object is being viewed, so I can’t just fix it with an offset. There are also places where I want the text to appear from the right hand side and increase to the left when it’s greater in size, having the last letter in a fixed position.
I don’t know of a way to make this work well, as far as i know you can’t even get a pixel width for the generated text. I just had a crappy hacky thought so i decided to post it.
This is a crazy hack but you could try getting a monospace-ish font and just find a good value for the average letter width. Using that width you could check the length of any string and multiply it by your letter width and use that value to offset your text appropriately. Just typing this out hurts me inside.
There is a function you can call that actually gets the size of the text string and returns two floats: the length and height. get the length, divide by 2 and assign where necessary. an example of this use is located in the HUD_example level in the example content download package in the marketplace. that’s how they center text on buttons.
Excellent, that is exactly what I needed. Cheers.
Mind blown. Much props. Please remember to upvote his answer!