Hi all guys, i have a question for you:
Is that any way to get the display.newText() dimension? i mean not the size, i mean total height and width. I need to know it because i want to put my text on a resizable image i have.
Thanks.
Hi all guys, i have a question for you:
Is that any way to get the display.newText() dimension? i mean not the size, i mean total height and width. I need to know it because i want to put my text on a resizable image i have.
Thanks.
Hi @ilparola,
After you create the text object, you can get its width and height as normal:
[lua]
local myTextObject = display.newText( “Hello World!”, 50, 50, “Arial”, 60 )
print( myTextObject.width, myTextObject.height )
[/lua]
Is this what you need, or do I not understand your request?
Brent
And if you want to get back the size of your original object factoring in its xScale and yScale as well, use object.contentWidth / contentHeight (or you can multiply the standard .width/.height times the scale yourself). Not sure if that’s part of the issue, but it can cause problems if you use just width / height on scaled objects…
Hi @ilparola,
After you create the text object, you can get its width and height as normal:
[lua]
local myTextObject = display.newText( “Hello World!”, 50, 50, “Arial”, 60 )
print( myTextObject.width, myTextObject.height )
[/lua]
Is this what you need, or do I not understand your request?
Brent
And if you want to get back the size of your original object factoring in its xScale and yScale as well, use object.contentWidth / contentHeight (or you can multiply the standard .width/.height times the scale yourself). Not sure if that’s part of the issue, but it can cause problems if you use just width / height on scaled objects…