I'm looking at the Hierarchy Example, and wondered how it is possible to rotate group2 around a specified anchor point.
I found that a bitmap has setAnchorPoint (not in docs though), but is it possible to apply this to a Sprite? I can do group2:setRotation(45), but I can't change the anchor point for that.
Edit: I just found this thread, and realise that you won't be doing it for sprites
http://www.giderosmobile.com/forum/discussion/85
Comments
What I would like is to set a pivot point, and then set the rotation in degrees, so that the bitmap/sprite rotates around that point.
Edit: I think what might be happening is a problem that I had with this in Objective C, where the Affine Transformations come into play.
I fixed it with this code:
http://stackoverflow.com/a/5666430/359578
but can't work out how to do that in Lua.
(CGAffineTransform slays me)
For example assume that you have a sprite
1. You need to put this sprite to a parent sprite:
parent:setRotation(45)
or
parent:setRotation(-45)
and have the pivot point at the neck point, rather than the center of the head.
I would do that with a child bitmap, I guess, which is what I'm experimenting with now.
I created a pivot texture to indicate where the point of rotation is, which made it a bit clearer:
<pre lang="lua">
-- my lua code
</pre>
There is one thing about your code, bitmap:setAnchorPoint works with ratios (usually between 0 and 1). Therefore it seems there is no need to get and use anchor point at function positionPivot.
That getting the anchor point was only to get a pivot png to show at the head png's pivot point, to indicate to me that it is really rotating where it should. A debugging thing, I guess.
Likes: Abiz