Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Weight point - Gideros Forum

Weight point

misterhupmisterhup Member
edited March 2016 in General questions
So basically I have a rectangle sprite and I want to rotate it, but I want to do that around a custom weight point (by default the weight point is situated in the middle of the sprite) which will be situated at the bottom of the sprite. So my question is: how to set a custom weight point?
I apologize if the question is very basic but I am new to Gideros. Also I apologize for any grammar mistakes I did.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited March 2016
    For Bitmaps:
    http://docs.giderosmobile.com/reference/gideros/Bitmap/setAnchorPoint#Bitmap:setAnchorPoint

    For Shapes
    You can draw shapes relatively to the position which you want to rotate around (0,0 position)

    Generic solution for Sprites and Sprite inherited objects:
    http://docs.giderosmobile.com/reference/gideros/Sprite/setAnchorPosition#Sprite:setAnchorPosition
    +1 -1 (+3 / -0 ) Share on Facebook
  • Is there a possibility to change the rotation-point of a shape after I created it?

    I had this problem when I did not draw the shape around its center. The :setAnchorPosition confuses me, because the anchor-position is not the same as the point of rotation.

    And another thing I don't get is the following:
    Bitmap inherits from Sprite. So it has :setAnchorPosition. It also has :setAnchorPoint. What is the difference here?

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    Bitmap:setAnchorPoint accepts ratios
    so
    bitmap:setAnchorPoint(0.5, 0.5)
    will always rotate around center

    but Sprite:setAnchorPosition accepts internal position.
    So
    sprite:setAnchorPosition(sprite:getWidth()/2, sprite:getHeight()/)
    should rotate around anchor point until sprite dimensions change (like adding a child)
Sign In or Register to comment.