Hi guys,
When I rotate a text object (that I fill with various content from a variable during game play) 90 degrees ccw, the position gets messed up. Depending on what text my text object is filled with, the text object moves to a new location. Both x and y. It is as if it looses track of its own center point when rotated. Is there a way to make a text stand still when rotated, regardless of what I fill it with? I always want the first letter in the word/sentence to be on the same place, ie aligned to the left at a fixed point.
As far as I know text objects do not have points like sprites do, just position and center (There is no “origin” point). I don’t believe they change when you rotate them.
If you’re wanting to get the leftmost point of the bounding box, you could always use the BoundingBoxLeft expression (ObjectName.BoundingBoxLeft).
Separately, some fonts do not have proper font height settings, or have a lot of extra space above the characters. You would need to manually adjust for that in your positioning.
That all said, I’ve done some testing with regular text and BB text, and rotating it doesn’t break anything with normal fonts as far as I can see:
Thanks for your detailed answer Silver-Streak!
Also thanks for the code you posted. I didn’t know about that debugging feature. That was really helpful. Here are two screenshots showing what is happening. I’m not sure why the distance between the origin and the center is changing but maybe it’s because of the font I am using, as you mentioned. I will try to implement that BoundingBox.Left expression you mentioned.
Actually I am a bit confused since Silver-Streak has managed to keep a permanent position with rotated text. I am still trying to find out what differs between his solution and mine.
Cheers
Farid
@Silver-Streak now I have changed the font to the standard font with the same result. The position is stable but the center point is moving depending on what is written. It doesn’t make any sense but maybe it can be related to the fact that I am getting the text from a json file on my computer?
I’m not sure why the text suddenly aligns to the left of the entire scene (that is why I added +40 at the end) but now the problem is solved. It would be great if it was possible to change the center point coordinates when rotating text boxes.