I am trying to make this app:
- User places finger on screen to be traced.
- A second finger traces around the first finger and an outline of the first finger should be drawn.(essentially just a drawing app that ignores the first finger being held on the screen)
Problem:
Instead of an outline it creates a star like shape. It seems that the line being drawn tries to connect to both touch points.
Question:
- Is there a way to ignore a specific touch in a multi touch app?
- Is there way to cancel the first touch in a single touch app?
My Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touchCount++;
NSLog(@"Touches Count: %i", touchCount);
if(touchCount >= 2)
{
drawingTouch = [touches anyObject];
CGPoint p = [drawingTouch locationInView:self];
[path moveToPoint:p];
drawingPoints = [[NSMutableArray alloc]init];
}
else
{
//???
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSArray *allTouches = [touches allObjects];
if(touchCount >= 2 && [allTouches count]>1)
{
UITouch *theTouch = allTouches[1];
CGPoint p = [theTouch locationInView:self];
[path addLineToPoint:p]; // (4)
[self setNeedsDisplay];
[drawingPoints addObject:[NSValue valueWithCGPoint:p]];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];// This was copied from a tutorial but I will remove it and see what happens.
}