我想通过使用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