我想通過使用UIRrotationGestureRecognizer旋轉SKSpriteNode。我已經實現了一個代碼,但有時候,當我旋轉節點時,它跳轉到一個不是它應該是的那個旋轉。在這裏,你有代碼:SKSpriteNode旋轉不正常
- (void) handleRotation:(UIRotationGestureRecognizer *) rotationrecognizer{
CGFloat initialrotation = 0.0;
if (rotationrecognizer.state == UIGestureRecognizerStateBegan) {
CGPoint touchLocation = [rotationrecognizer locationInView:rotationrecognizer.view];
touchLocation = [self convertPointFromView:touchLocation];
[self selectNodeForTouch:touchLocation];
initialrotation = selected.zRotation;
}
else if (rotationrecognizer.state == UIGestureRecognizerStateChanged) {
CGFloat angle = initialrotation + rotationrecognizer.rotation;
selected.zRotation = angle;
}
}
考慮到我確實已經解決了您的代碼的一個根本問題,您將不勝感激並接受我的答案。 – MobileVet