如何将精灵的角度设置为45度?
SKAction *rotate = [SKAction rotateByAngle: M_PI/4.0 duration:1];
Run Code Online (Sandbox Code Playgroud)
只是将角度增加了45度,我想要做的就是SKSprite旋转,但需要长时间才能达到45度然后停止.有没有方法或我必须硬编码?
谢谢!
您正在寻找的方法是+rotateToAngle:duration:shortestUnitArc:,如:
SKAction *rotate = [SKAction rotateToAngle:M_PI_4 duration:1 shortestUnitArc:YES];
Run Code Online (Sandbox Code Playgroud)
你也可以使用+rotateToAngle:duration:,但它总是逆时针旋转; 这种变体适用于需要最少旋转的方向.
(还要注意π/ 4已经定义为常量,M_PI_4;参见usr/include/math.h)
| 归档时间: |
|
| 查看次数: |
602 次 |
| 最近记录: |