Right now I display the user’s score in the upper left of the screen. It displays like this… SCORE:0
When the score increases I want it to say… SCORE:100
Right now when it increases in digits, the numbers overlap the word “SCORE”. For example, the 1 would be on top of the “E” and one of the 0’s would be on top of the “:”.
How can I get the number to grow to its right rather than left?
[import]uid: 39238 topic_id: 7380 reply_id: 307380[/import]
You need to set the position of the text object again( even if it didn’t change, you need to set it ).
scoreNumText.text = “1101”
scoreNumText:setReferencePoint(display.CenterLeftReferencePoint)
scoreNumText.x = 60
That should get the text display object to justify the text. Hope this helps
Mark [import]uid: 8673 topic_id: 7380 reply_id: 26112[/import]
I have the same problem as divac7777 does. I have a line of text left justified an the top left, and when I append different strings of digits to the end, it changes its position. The solution suggested by mhorsley, and also by Ansca at http://developer.anscamobile.com/content/display-objects, does not work for me.
Here is my hack of a workaround:
--include padding for longest addition expected
catSeenText = display.newText("Cats Seen ", catTextX, catTextY, fontName, 12)
catSeenText:setTextColor(180, 180, 180)
catSeenText:setReferencePoint(display.CenterLeftReferencePoint)
catSeenText.x = catTextX
catSeenText.y = catTextY
Then later, depending on the score:
--this is a hack workaround to keep text from moving when score changes
if catsSeen \> 99 then
catSeenText.text = "Cats Seen "..tostring(catsSeen) --no padding
elseif catsSeen \> 9 then
catSeenText.text = "Cats Seen "..tostring(catsSeen).." " --add one space
else
catSeenText.text = "Cats Seen "..tostring(catsSeen).." " --add two spaces
end
catSeenText:setReferencePoint(display.CenterLeftReferencePoint)
catSeenText.x = catTextX
catSeenText.y = catTextY
This is still not perfect. There is still some shifting of the displayed character string (as if it were center aligned), depending on the width of the digits in the score, but it’s better than before.
[import]uid: 23636 topic_id: 7380 reply_id: 30519[/import]