且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在SpriteKit中使用touchesMoved旋转奖品轮

更新时间:2023-01-23 19:04:35

应用你的冲动后:

[node.physicsBody applyAngularImpulse:theImpulse];

只需将角速度钳制到最大速度,其最大速度取决于您想要允许车轮的速度旋转:

Simply clamp the angular velocity to a maximum speed whose value depends on how fast you want to allow the wheel to spin:

const CGFloat maxAngularVelocity = 2.5;
node.physicsBody.angularVelocity = MIN(node.physicsBody.angularVelocity, maxAngularVelocity);