2

为了使用 OpenGL 编辑图像,我提供了用户交互,当用户移动手指时,图像会根据拖动方向进行编辑。但我想限制拖动。例如,用户应该只编辑鼻子的一部分,如果拖动不受限制,我的图像纹理会失真,因为用户有机会将他/她的手指拖动到整个屏幕或脸部(更具体地说)。

//这里是代码

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
    count++;
    NSLog(@"touches moved called");
    UITouch *touch = [[touches allObjects] objectAtIndex:0];
    if(count>2)
    {
        NSLog(@"Entered");
        count=0;
        self.view.userInteractionEnabled=NO;
    }
    else{
        updatepoint = [touch locationInView:self.view];
        mousex = updatepoint.x;
        mousey = self.view.bounds.size.height-updatepoint.y;
        grab = [self ripple_grab:mousex:mousey];
        [self drawFrame];
    }
}
4

1 回答 1

3

我得到了解决方案

这是我更新的代码。如果有其他方法,请给我建议。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    count = 0;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
    count++;
    NSLog(@"touches moved called");
    UITouch *touch = [[touches allObjects] objectAtIndex:0];
    if (count > 6)
    {
        NSLog(@"Entered");
       // count=0;
       // self.view.userInteractionEnabled = NO;
       //NSLog(@"line skipped");
    }
    else{
        NSLog(@"else Entered");
        updatepoint = [touch locationInView:self.view];
        mousex = updatepoint.x;
        mousey = self.view.bounds.size.height-updatepoint.y;
        grab = [self ripple_grab:mousex:mousey];
        [self drawFrame];
    }
}
于 2012-08-27T12:50:33.263 回答