旋转 Cocos2d 精灵以匹配操纵杆
我在 Cocos2d 中使用 SneakyJoystick,并且尝试让精灵旋转以面向与操纵杆指向相同的方向(这是自上而下)。
我可以让它旋转以面对它,但随着旋转每帧左右更新,它会卡入到位。
如何让精灵平滑地朝目标角度旋转,而不跳到目标角度?我无法弄清楚如何使用 CCRotateTo 执行此操作,因为旋转的角度可能随时发生变化。
I'm using a SneakyJoystick in Cocos2d, and I'm trying to get a sprite to rotate to face the same direction as the joystick is pointed (this is top down).
I can get it to rotate to face it, but it snaps into position as the rotation is updated every frame or so.
How can I make the sprite rotate smoothly towards the target angle, without jumping to it? I wasn't able to figure out how to do this with a CCRotateTo because the angle to rotate towards could change at any time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终通过使用我制作的旋转方法简单地解决了这个问题,该方法在每次更新时以正确的量沿正确的方向旋转节点/精灵。
I ended up fixing this simply by using a rotation method that I made, which rotates the node/sprite in the correct direction at the correct amount each update.
您是否尝试过:
获取上次更新与当前更新之间的角度,如果您想要角色有设定的转身时间,您可以根据角度大小来缩放持续时间。
Have you tried:
Obtain the Angle between the last Update the current Update, also if you wanted it so the character had a set time to turn around, you can scale your duration by the amount of the angle.