我试图使用 UIPanGestureRecognizer 来移动我的对象,但我似乎无法让它顺利移动。当我朝一个特定的方向移动并转向相反的方向时,它不会立即做出反应。我认为该值可能有问题,因为它在“->”方向上为正,在“<-”方向上为负。
我的代码如下:
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{
CGPoint pointA = [panRecognizer locationInView:self.view];
CGPoint pointB = [panRecognizer translationInView:self.view];
if(panRecognizer.state == UIGestureRecognizerStateEnded ||
panRecognizer.state == UIGestureRecognizerStateChanged) {
_camera.x += pointB.x * 0.0001f;
}
}
有没有人有更合适的方法来解决这个任务?
提前致谢。