function button_1:touch(e)
if(e.phase == “ended”) then
txt.text = txt.text … self.buttonString
txt:setReferencePoint(display.CenterLeftReferencePoint);
txt.x = 100;
end
end
After 4 hours of digging I found the solution deep within the forums…
You can simply paste this code on the first line of your main.lua file…
local OldnewText = display.newText
display.newText = function( text, xPos, yPos, font, size ) local actualText = text or “” local actualFont = font or “Helvetica” local actualSize = size or 16
local xScale, yScale = display.contentScaleX, display.contentScaleY local sizeMultiply = 1
if xScale < 1.0 or yScale < 1.0 then sizeMultiply = 2 end
local t = OldnewText( actualText, 0, 0, actualFont, actualSize * sizeMultiply ) t:setReferencePoint( display.TopLeftReferencePoint )
Here is the iPhone 4 code that I got working… is there a way to switch between these automatically?
local OldnewText = display.newText
display.newText = function( text, xPos, yPos, font, size )
local actualText = text or “”
local actualFont = font or “Helvetica”
local actualSize = size or 16
local xScale, yScale = display.contentScaleX*2, display.contentScaleY*2
local sizeMultiply = 1
if xScale < 1.0 or yScale < 1.0 then
sizeMultiply = 2
end
local t = OldnewText( actualText, 0, 0, actualFont, actualSize * sizeMultiply )
t:setReferencePoint( display.TopLeftReferencePoint )
There’s no simple API to align text at this stage, if you think there is an issue (your code should work but for some reason it doesn’t) then please file a bug report, then post your case number here.
byronfillmore, since you made your posts the forum has some more people around - previously questions were often missed - however if you have an urgent problem and are not getting answers then you can in touch by, as I said above, filing a bug report. (If there is an actual bug.)
Try removing the scaling. Scaling is centered on the reference point which might not be what you want here.
If you simply HAVE to have the scaling, when you update the text you should first reset the reference point to display.CenterReferencePoint, reset the scaling to 1, 1, change the text, THEN set the alignment with the CenterLeftReferencePoint, new x, and new scaling. Or something like that. [import]uid: 6787 topic_id: 10566 reply_id: 45108[/import]