0
votes

I'm anew cocos2d developer and I have a tiny problem and i need your help..

Actually i need to rotate a Sprite around the screen center, i put the position to the screen center and the anchor point to (-1,-2) for example and i did the rotate.

NOW my problem that i need to know the real position for the sprite after the rotation , every time i tried to read the position i got the screen center point and that's what i do not need.

Is there a way Or method to get the real position for Sprite??

2

2 Answers

1
votes

Let the centre point be(x1,y1) and the sprite is at (x2,y2), then distance between them is http://www.purplemath.com/modules/xyplane/dist07b.gif

0
votes

The sprite's position IS it's anchor point. Wherever the sprite's anchor point is on the screen, that is it's position. Normally this is the center of the sprite, but if you change the sprite's anchor point then it won't be the center. I'm not quite certain on the math but I expect you would add the difference (from sprite center to it's new anchor point) to it's rotation.