Can't get text alignment to work :'(

Hi guys,

It’s been a while since I last played with Corona, but I have returned and fell in love with it again.
I ran into an issue though, one that I’ve been spending far too much time on to fix, but I am completely lost.

I’m trying to get a newRetinaText() to align left (after changing the text), but it seems like the longer the new string is, the further tot he right the text is placed.

This is the code, throw it in a lua file and see for yourself

local randomText = display.newRetinaText("test", 0, 0, system.defaulFont, 20)  
randomText:setReferencePoint(display.TopLeftReferencePoint)  
randomText.x = 100  
randomText.y = 200  
  
function randomText:enterFrame(event)  
 self.text = "monkey"..math.pow(10, math.random(0, 10))  
 self:setReferencePoint(display.TopLeftReferencePoint)  
 self.x = 100  
end  
  
Runtime:addEventListener("enterFrame", randomText)  

I’m sure I’m overlooking something simple, but I’m afraid I’ll go crazy if I keep trying.
Thanks for any help :slight_smile:

Nick [import]uid: 7980 topic_id: 21033 reply_id: 321033[/import]

Weird - when i change newRetinaText to newText it works perfectly, with the huge downside of it looking like crap on a retina screen. Any workarounds for this? [import]uid: 7980 topic_id: 21033 reply_id: 83095[/import]

Ziao, try use :setText() instead of .text and see if it works [import]uid: 14018 topic_id: 21033 reply_id: 83097[/import]

Thanks for your quick reply, Mitaten.

Unfortunately, I don’t think the setText method is available for text objects, seeing how I get this error:

main.lua:41: attempt to call method ‘setText’ (a nil value)

[import]uid: 7980 topic_id: 21033 reply_id: 83098[/import]

Regarding retina text:

display.newText() has been modified to handle “retina text” automatically, and therefore display.newRetinaText() has been deprecated since it is no longer needed.

The changes will be reflected in the next daily build (the one posted *after* 2012.770).
[import]uid: 52430 topic_id: 21033 reply_id: 94933[/import]

Great! Thanks for the update :slight_smile: [import]uid: 7980 topic_id: 21033 reply_id: 94954[/import]