在精灵外部的锚点上旋转 cocos2d 精灵

发布于 2024-09-02 16:59:33 字数 98 浏览 0 评论 0原文

目前 setanchor 函数仅在精灵框架内设置锚点。是否有任何(更简单的)方法将锚点更改为屏幕空间上的坐标?我的目的是让精灵绕一圈旋转。

TIA 提出的任何建议。

Currently the setanchor function only sets the anchor within the sprite frame. Is there any (easier) wway to change the anchor point to a coordinate on screen space? My purpose is to allow the sprite to rotate around a circle.

TIA for any suggestions made.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2024-09-09 16:59:33

使用节点层次结构对您有利。创建一个新节点(除非您希望它可见,否则它将不可见)并将您的精灵作为子节点添加到该节点。例如,通过将位置设置为 100、100,将精灵子元素放置在稍远的位置。

现在,如果您使用旋转属性(而不是精灵)旋转节点,则精灵应该随节点一起旋转,使其看起来好像绕了一圈。节点本身将成为旋转的中心点。

我已将此问答添加到我的 cocos2d 常见问题解答中:
http://www.learn-cocos2d.com/knowledge-base/cocos2d-iphone-faq/learn-cocos2d-public-content/manual/ cocos2d-general/14826-如何以圆周运动旋转精灵

Use the Node hierarchy to your advantage. Create a new Node (which won't be visible unless you want it to be) and add your sprite to the node as children. Position the sprite child somewhat away by giving it a position of 100, 100 for example.

Now if you rotate the node using the rotation property, instead of the sprite, the sprite should rotate with the node, making it appear as if it goes around in a circle. The node itself will be the centerpoint of the rotation.

I've added this Q&A to my cocos2d FAQ:
http://www.learn-cocos2d.com/knowledge-base/cocos2d-iphone-faq/learn-cocos2d-public-content/manual/cocos2d-general/14826-how-to-rotate-a-sprite-in-a-circular-motion

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文