精灵位置
我是一个新的 cocos2d 开发人员,我有一个小问题,我需要你的帮助..
实际上我需要围绕屏幕中心旋转 Sprite,我将位置放在屏幕中心并将锚点设置为 (-1,-2 )例如,我进行了旋转。
现在我的问题是,我需要知道旋转后精灵的真实位置,每次我尝试读取位置时,我都会得到屏幕中心点,而这正是我不需要的。
获取 Sprite 真实位置的方式或方法?
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设中心点为(x1,y1),精灵位于(x2,y2),则它们之间的距离为 http://www.purplemath.com/modules/xyplane/dist07b.gif
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
精灵的位置是它的锚点。无论精灵的锚点在屏幕上的什么位置,这就是它的位置。通常这是精灵的中心,但如果更改精灵的锚点,那么它就不会是中心。我不太确定数学,但我希望您将差异(从精灵中心到它的新锚点)添加到它的旋转中。
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.