does Director cause text to be centered initially instead of placed at top left?

I’m trying to simply create 3 lines of text, left-justified, like so:

[lua]local txtOne = display.newText( localGroup, “First Line”, 100, 400, “Arial”, 24)
local txtTwo = display.newText( localGroup, “Second Line”, 100, 425, “Arial”, 24)
local txtThree = display.newText( localGroup, “Third Line”, 100, 450, “Arial”, 24)[/lua]

But what I am seeing is that the first line is at x=100, but then the 2nd and third lines appear to be centered about 50 pixels to the right, and not even centered or left justified at the same point.

This seems like it should be simple. Am I missing something obvious? [import]uid: 82378 topic_id: 24786 reply_id: 324786[/import]

Director isn’t doing this I don’t think. I think it’s the fact that the default for display objects is “Center Reference Point”.

Try putting:

txtOne:setReferencePoint(display.TopLeftReferencePoint)
txtOne.x = 100
txtOne.y = 400

and see if that fixes you up. I’ve never had much luck depending on the X, Y in things like that to actually work the way I want.

[import]uid: 19626 topic_id: 24786 reply_id: 100557[/import]

For the setReferencePoint to work, one thing I always needed to do is to set the text before I set the setReferencePint. And then after the reference point is set, I set the x & y. It always works without fail.

If I change the text, I then again set the reference point and, again, set the x & y – but I usually don’t need to reset y, because I always make the y the same – if the text is single line text, no need to change, and if the text is multiline text, I always choose top alignment for y.

Here’s a thread that helped me learn the nature of the text object. It really helped to learn how to align the text object the way I want:

https://developer.anscamobile.com/forum/2011/08/27/text-alignment-bug

Naomi [import]uid: 67217 topic_id: 24786 reply_id: 100593[/import]

Thanks very much Naomi, that fixed it. I forgot to mention in my initial post that I had tried changing the Reference point to TopLeft one time, just after creating the object. And then I was resetting the x every time after changing the text. But once I did both after every time I changed the text, it worked. I still don’t fully understand why, even after reading the docs on setReferencePoint.

I also think this should be added to the Docs page on creating Text objects. [import]uid: 82378 topic_id: 24786 reply_id: 100602[/import]

Glad to hear it helped :slight_smile:

Naomi [import]uid: 67217 topic_id: 24786 reply_id: 100612[/import]