object.text

Type String
Object TextObject
Library display.*
Revision Release 2024.3703
Keywords text, string, label
See also textObject.size
display.newText()

Overview

Retrieves or sets the text string of a text object.

Gotchas

When you change the text string of a text object, you should also reset its anchor point and x/y position again. Doing this ensures that the object remains aligned to the original position.

Example

local myText = display.newText( "Hello", 0, 0, native.systemFont, 12 )
myText.x = 50 ; myText.y = 50
myText:setFillColor( 1, 1, 1 )
myText.anchorX = 0

-- Change the text
myText.text = "Hello World!"