Problem with placing my text automatically

Hi,

I have some words I want to place in my scene.

Each word has to be touchable so I want to use individual textObjects.

I thought I could autospace them by using some math. But I found out my math sucks.

What I am doing is taking the x position of word1 (100) add its width (55) and then add 10 to that number to space it a bit from the word. 

This should work if the xReference is 0, but it doesn’t. So I tried dividing the width by 50% but still not spacing correctly.

Any ideas on how I could achieve this?

[lua]

local word1=newText(group,“Foobar”)

word1.x=myWidth*0.25

word1.y=myHeight*0.92

local word2=newText(group,“barFoo”)

woord2.x=(word1.x + (word1.width/2)+10) – if the center point for text is in the middle else without the /2

woord2.y=myHeight*0.92

[/lua]

When text is created, reference point is in the center. So you must add half of second word width. You can also move reference point position using display.setReferencePoint

thanks, yeah figured that out this morning when I woke up.  Guess sleeping on it really works.

I tried the reference point thing yesterday, somehow that didn’t yield any good results. 

When you are using standard version of newText (in the last bulid 2013.1202 there is second version behaving slightly different), constructor x and y parameter refers to top left point. When text is already created, x and y properties refers to the center of whole text.

Actually @piotrz55, for most of the API calls, if you provide an X, Y as a passed in parameter vs. setting the .x, and .y separately it’s assumed to be the Top Left point for the function call only.  After that accessing .x and .y are by default from the center.   It’s been that way for a long time.

I assume you just tell me to confirm, because I’ve written the same, haven’t I? :slight_smile:

When text is created, reference point is in the center. So you must add half of second word width. You can also move reference point position using display.setReferencePoint

thanks, yeah figured that out this morning when I woke up.  Guess sleeping on it really works.

I tried the reference point thing yesterday, somehow that didn’t yield any good results. 

When you are using standard version of newText (in the last bulid 2013.1202 there is second version behaving slightly different), constructor x and y parameter refers to top left point. When text is already created, x and y properties refers to the center of whole text.

Actually @piotrz55, for most of the API calls, if you provide an X, Y as a passed in parameter vs. setting the .x, and .y separately it’s assumed to be the Top Left point for the function call only.  After that accessing .x and .y are by default from the center.   It’s been that way for a long time.

I assume you just tell me to confirm, because I’ve written the same, haven’t I? :slight_smile: