是否可以围绕SpriteKit中的任意点旋转节点? [英] Is it possible to rotate a Node around an arbitrary point in SpriteKit?

查看:270
本文介绍了是否可以围绕SpriteKit中的任意点旋转节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法围绕任意点在SpriteKit中旋转节点?
我现在可以操作我的Node的 anchorPoint ,但如果我想要使用的旋转点位于Node之外,那还不够。

Is there a way to rotate a Node in SpriteKit around an arbitrary point? I now I can manipulate the anchorPoint of my Node, but that is not sufficient if the rotation point I want to use lies outside of the Node.

在SpriteKit中实现这种轮换的最佳方法是什么?

推荐答案

由于您要求最佳方式,这里的效果很好(最好是主观的):

Since you're asking for the best way, here's one that works well (best is subjective):

创建一个SKNode将其位置设置为旋转中心。将应该围绕该中心旋转的节点添加到中心节点。将子节点的位置设置为所需的偏移量(即半径,比如x + 100)。更改中心节点的旋转属性以使子节点围绕中心点旋转。同样适用于cocos2d btw。

Create an SKNode and set its position to the center of rotation. Add the node that should rotate around that center as child to the center node. Set the child node's position to the desired offset (ie radius, say x + 100). Change the rotation property of the center node to make the child node(s) rotate around the center point. The same works for cocos2d btw.

这篇关于是否可以围绕SpriteKit中的任意点旋转节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆