Hi.
Some functions return a sprite and I can use getWidth() and getHeight() to get the width and height of that sprite, but how can I get the bounds of it instead?
"Sprite:getHeight()
Returns the height of the sprite, in pixels. The height is calculated based on the bounds of the content of the sprite."
local MyTextField = TextField.new(MyFont, "LLLyyy")
MyTextField:setPosition(100, 100)
stage:addChild(MyTextField)
How do I move this text to the upper left corner of the stage? setPosition(0, 0) doesn't work, as that puts most of the text above the stage.
Right now I do this:
MyTextField:addChild(PixelAtRow1000)
MyTextField:setPosition(MyTextField:getHeight()-1000, 0)
MyTextField:removeChild(PixelAtRow1000)
But isn't there a better way, like a getUpperBound() function?
Comments
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Hopefully I'll introduce setAnchorPoint function for TextFields so that you'll be able to align the texts to the ascender.
Thank you very much for your time.
Sprite:getBounds(parent)
Returns the screen bounds of the sprite (4 values) relative (I suspect) to the specified parent (usually "stage"), VERY useful for working out the bounds of complex Sprites (or centring text)
Returns:
x,y,width,height
eg.
Likes: unlying, kae
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill