How to rotate an SKSpriteNode around the node's Y-axis?

后端 未结 4 2032
执笔经年
执笔经年 2020-12-28 20:37

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,

4条回答
  •  北海茫月
    2020-12-28 21:35

    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.

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

    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.

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

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

    enter image description here

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

    enter image description here

提交回复
热议问题