Multitouch tracking issue

后端 未结 2 1130
有刺的猬
有刺的猬 2020-12-11 22:40

I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user rights, I followed this link How

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 22:58

    If I understood your problem correctly, you're having undesired strokes whenever the user uses multiple fingers on your canvas. Since you already have a self.trackingTouch, will it be reasonable to just ignore every other touch that is not self.trackingTouch?

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        if (self.trackingTouch)
        {
            // another touch is active so we ignore this one
            return;
        }
        // ...the rest of your code
    }
    
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = self.trackingTouch;
        if (![touches containsObject:touch])
        {
            // updates to touches other than self.trackingTouch
            return;
        }
    
        // ...process only self.trackingTouch in the rest of your code
    }
    
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = self.trackingTouch;
        if (![touches containsObject:touch])
        {
            // updates to touches other than self.trackingTouch
            return;
        }
    
        // ...process only self.trackingTouch in the rest of your code
    
       self.trackingTouch = nil;
    }
    
    -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
    {
        // ...same as touchesEnded:withEvent:
    }
    

提交回复
热议问题