如何围绕节点的Y轴旋转SKSpriteNode? [英] How to rotate an SKSpriteNode around the node's Y-axis?

查看:106
本文介绍了如何围绕节点的Y轴旋转SKSpriteNode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试围绕其Y轴旋转SKSpriteNode节点.我知道有zRotation属性,它将使节点顺时针或逆时针旋转;但是,我想绕其自身的Y轴旋转该节点(例如,像跳舞的芭蕾舞演员),而我似乎找不到任何功能.推荐的最佳做法是什么?

I'm trying to rotate an SKSpriteNode node around it's Y-axis. I know there's the zRotation property and that will rotate the node clockwise or counter-clockwise; however, I'd like to rotate the node around it's own Y axis (like a dancing ballerina for instance), and I can't seem to find any functionality to do so. What is the best recommended way of doing this?

推荐答案

通常,如果我要旋转看起来像您正在描述的内容,并希望它看起来不错,我将通过描述不同角度的子帧来实现.回转.

Typically if I am wanting to rotate something like you seem to be describing, and want it to look good, I will do it via sprite frames depicting different degrees of rotation.

您确实可以通过将xScale属性从1过渡到-1,反之亦然来伪造一点.

You can indeed fake it a little by tweening your xScale property from 1 to -1 , and visa versa.

对于卡片(或纸上的马里奥)来说,xScale技巧是可行的,但是对于芭蕾舞演员来说,并不是很多.您正在寻找2D对象的3D旋转,而通过这种方法不会发生这种情况.

The xScale trick is feasible for cards maybe (or paper mario), but for a ballerina, not so much. You are looking for 3D rotation of a 2D object, and that's not going to happen via that method.

因此,如果xScale技巧无法满足您的需求,则需要通过Sprite框架进行处理.

So if the xScale trick is not feasible for your needs, you'll need to handle it via sprite frames.

以下是3d SpriteSheet的示例,该示例可让您实现所需的旋转:

Here's an example of a 3d SpriteSheet that would allow you to achieve the rotation you desire :

此动画gif是一个用于使y旋转的精灵帧的示例:

This animated gif is an example of sprite frames to get that y rotation :

这篇关于如何围绕节点的Y轴旋转SKSpriteNode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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