Hi Tom,
I originally noticed this issue upon upgrading to .883 and running a build I haven’t touched in a few weeks. The build was using my Typer() code, which basically works like this:
- Set the string to “”
- Use … to add each character to the string in a timed fashion
- Reset the reference point, but do not restate the x/y positions.
So as best I can tell, if you do this:
- Set an existing string using TopLeft to “”
- Set the reference point back to TopLeft
- Set the existing string to a real word
Pre 880 builds: Text string is written using the existing X/Y position and reference point
883: Text string is written using either a center reference point or some modified position.
Here’s some sample code; in 870 series the text would start from the same reference point.
[code]-- TEST PROJECT: Find out what’s going on with text objects that become empty.
– ? To test, press anywhere on screen to update the text.
– Output to console (needed for SublimeText2 to show print(“statements”))
io.output():setvbuf(“no”)
– Create the background clickable object
local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
background:setFillColor(0, 0, 0)
– Create the text object
local textObject = display.newText(“Hello!”, 30, 30, “HelveticaNeue”, 18)
textObject:setReferencePoint(display.TopLeftReferencePoint)
print(“textObject.x, textObject.y”, textObject.x, textObject.y) – reports 30, 30
– FUNCTION: Prints a new string. (Called by wipeText)
local function newString()
textObject:setReferencePoint(display.TopLeftReferencePoint)
textObject.text = “Tappity tap tap”
textObject:setReferencePoint(display.TopLeftReferencePoint)
print(“textObject.x, textObject.y”, textObject.x, textObject.y) – reports -8, 29 as the new position
end
– FUNCTION: Wipes the text and then displays a new String.
local function wipeText()
textObject.text = “”
textObject:setReferencePoint(display.TopLeftReferencePoint)
timer.performWithDelay(200, newString)
end
– Add wipeText as a touch function
background:addEventListener(“touch”, wipeText)[/code]
(The number of reference point lines is probably excessive; I can get the same result with less, but for troubleshooting sake they are all there to enable/disable at will.)
[import]uid: 41884 topic_id: 30117 reply_id: 120672[/import]