display.newText() - how to left align?

Seems like rendering text in this way always pegs it to the middle. Then when I change the text it goes off from where I want it to be. I don’t see any API to deal with this. Any ideas? [import]uid: 21280 topic_id: 5768 reply_id: 305768[/import]

http://developer.anscamobile.com/reference/index/objectsetreferencepoint [import]uid: 23949 topic_id: 5768 reply_id: 19769[/import]

Nice one, it works. It just a little awkward and odd workaround. [import]uid: 21280 topic_id: 5768 reply_id: 19771[/import]

Seems ok to me. After all, it’s a general method for all display objects not just text. I’m new at Corona myself, so maybe there’s a better way. [import]uid: 23949 topic_id: 5768 reply_id: 19774[/import]

Your code is perfectly fine, the display API is what could do with some improvement IMHO. Setting reference point once for text should peg it there without the need to reset the ref point and the coordinates.
[import]uid: 21280 topic_id: 5768 reply_id: 19776[/import]

This wont work for me. Here’s my code:

showScore = display.newText(\_G.score, 14, 8, "Helvetica")  
showScore:setTextColor(0, 0, 130)  
showScore.size = 14  
showScore:setReferencePoint(display.CenterLeftReferencePoint)  

And when object collides with coin:

\_G.score = \_G.score + 15  
showScore.text = \_G.score  
showScore:setReferencePoint(display.CenterLeftReferencePoint)  

Why wont it work? [import]uid: 30185 topic_id: 5768 reply_id: 21283[/import]

issue remains… dno why it doesntw ork [import]uid: 30185 topic_id: 5768 reply_id: 21575[/import]

It’s not clear to me what isn’t working for you. Can you give more detail? [import]uid: 23949 topic_id: 5768 reply_id: 21578[/import]

The align… I set align + reference point to showScore, then I’ve got a collision function that is triggered everytime the object collides with a coin, and inside this function it updates the score… but the align wont work and it sets the numbers to middle… [import]uid: 30185 topic_id: 5768 reply_id: 21581[/import]

Is the text in a group that could be affecting its placement? Have you tried to making your text object physics objects (static) and then set physics debugging mode so you can see their bounds? I also find text reference points don’t always behave as I expect…

I’m not in front of any code at the moment, and I’m also a beginner at Corona. Sorry I can’t be more helpful. Maybe if you post some code? [import]uid: 23949 topic_id: 5768 reply_id: 21583[/import]

yeah, showScore is inside a group, but that group only exists to place the score variables in front, they’ve got no align or ref points… i havnt tested the physcs/bounds thing, how do I check bounds?

thanks i appreciate your help! [import]uid: 30185 topic_id: 5768 reply_id: 21585[/import]

Hopefully you have this page bookmkared :slight_smile: http://developer.anscamobile.com/resources/apis/

try

[lua]physics.setDrawMode( “debug” )[/lua] [import]uid: 23949 topic_id: 5768 reply_id: 21588[/import]