gpt4 book ai didi

ios - 在 SpriteKit 中设置 Sprite 的角度

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:14 25 4
gpt4 key购买 nike

如何将 Sprite 的角度设置为 45 度?

SKAction *rotate = [SKAction rotateByAngle: M_PI/4.0 duration:1];

仅将角度增加 45 度,我想做的是必须 SKSprite 旋转到 45 度然后停止。有没有办法解决这个问题,还是我必须对其进行硬编码?

谢谢!

最佳答案

您正在寻找的方法是+rotateToAngle:duration:shortestUnitArc:,如:

SKAction *rotate = [SKAction rotateToAngle:M_PI_4 duration:1 shortestUnitArc:YES];

你也可以只使用+rotateToAngle:duration:,但它总是逆时针旋转;此变体朝需要最少旋转的方向移动。

(另请注意,π/4 已定义为常量,M_PI_4;请参阅 usr/include/math.h)

关于ios - 在 SpriteKit 中设置 Sprite 的角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22388796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com