Rotating a text object, messes up it's coordinates

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.

Here is a screenshot showing what I want to do:

Cheers

Farid

Please, give us the problem screenshot. The normal screenshot you have already attached.
Are you rotate the text object after write on it?

This is what it looks like in the editor:

This is what it looks like when running the app and the first question in the quiz:

This is what it looks like in the second question. As you can see the text has moved to the left side of the scene:

You can also see that the three alternatives on the top of the scene are jumping around. In this case I haven’t done any wrapping but still…

Any idea of whats happening?

Cheers

Farid

That should be a bug report. Probably already had been reported (if that really is a bug). it’s quite unfortunate.

What I can think of doing for now is make offset positions that correspond to the angle of the text objects.

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:

https://game-previews.gdevelop-app.com/1659464992426-237621/index.html
(Press A on the keyboard to rotate the two text objects)

Note that the “position” is the real position of the object before it is rotated, 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.

Below you can see how it changes.

Cheers

Farid

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?

Cheers

Farid

No, that makes sense just fine. Text automatically adjusts its object width to the total width of the text within it.

If you add or change the text bring displayed, the object will become wider or thinner. The center of the object would move as well.

Actually I solved it with a little help from a friend who knows JS/css. Here is what she told me to do and it worked:

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.

Cheers

Farid