4
是否可以使用applyAngularImpulse而不是按指數方式增加輪子的速度?
理想情況下,我想讓車輪跟隨我的手指,但設置node.zRotation += atan2f(y2-y1, x2-x1)
讓我的車輪失去控制。這是我看中了,但感覺很靠不住的:在SpriteKit中使用touchesMoved旋轉獎金輪
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
SKNode *node = [self nodeAtPoint:location];
CGPoint positionInScene = [touch locationInNode:self];
CGPoint previousPosition = [touch previousLocationInNode:self];
[node.physicsBody applyAngularImpulse:(previousPosition.x - positionInScene.x) * 0.1];
node.physicsBody.angularDamping = 1;
}