Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How setAnchorPosition of Sprite work? — Gideros Forum

How setAnchorPosition of Sprite work?

edited September 2015 in General questions
Hi everyone,
I just think setAnchorPosition work as same as setAnchorPoint of Bitmap. But when using for TextField (Inherits Sprite), it not works as expected. Maybe this is a bug?
 
local textfield = TextField.new(nil, "some other text with default font")
 
textfield:setAnchorPosition(0.5,0.5)
textfield:setPosition(0,0)
stage:addChild(textfield)
 
textfield:setRotation(45)

Coming soon

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    Hello, if they would work the same, they would have the same name, setAnchorPoint

    but in this case it is setAnchorPosition, so you need to provide position in logical dimensions where you want the anchor point to be.

    If you want to achieve effect like on 0.5,0.5 anchor point then you would need to get width and height of the textfield and divide them by 2 and set as anchor positions.

    Reason for such difference is because Sprites contents may change and thus changing the width and height of sprite
  • @ar2rsawseen a ha, thank so much for detail explain. So setAnchorPosition get position as input. Thanks!
    Coming soon
Sign In or Register to comment.