Skip to content

Commit

Permalink
creating quadrangles with 4 fingers
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol S. Mazur committed Mar 22, 2012
1 parent 2d3de20 commit 713a714
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions MovingShapes/ShapeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- (void)shapeViewDidMoveVertex: (NSInteger) vertex toPoint: (HKPoint *) point;
- (void)shapeViewDidTouchWithOnePoint:(HKPoint*) point;
- (void)shapeViewDidTouchWithThreePoints:(NSArray *)points;
- (void)shapeViewDidTouchWithFourPoints:(NSArray *)points;
- (void)shapeViewDidMoveByX: (CGFloat) x y: (CGFloat) y;
@end

Expand Down
3 changes: 3 additions & 0 deletions MovingShapes/ShapeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ - (void) processTouchEvent:(UIEvent *)event {
case 3:
[delegate shapeViewDidTouchWithThreePoints: points];
break;
case 4:
[delegate shapeViewDidTouchWithFourPoints: points];
break;
}
}

Expand Down
24 changes: 16 additions & 8 deletions MovingShapes/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ - (void)shapeViewDidMoveByX: (CGFloat) x y: (CGFloat) y {
[self.view setNeedsDisplay];
}

- (void)updateShapeWithPoints:(NSArray*) points {
if (shape) {
[shape updatePoints: points];
} else {
shape = [[Shape alloc] initWithPoints: points];
[(ShapeView *) self.view setShape: shape];
}

[self.view setNeedsDisplay];
}

- (void)shapeViewDidTouchWithThreePoints:(NSArray *)points {
NSLog(@"3 points: %@", points);
[self updateShapeWithPoints:points];
}

if (shape) {
[shape updatePoints: points];
} else {
shape = [[Shape alloc] initWithPoints: points];
[(ShapeView *) self.view setShape: shape];
}

[self.view setNeedsDisplay];
- (void)shapeViewDidTouchWithFourPoints:(NSArray *)points {
NSLog(@"4 points: %@", points);
[self updateShapeWithPoints:points];
}

- (void)gyroscopicDidUpdateRotation:(float)rotation {
Expand Down

0 comments on commit 713a714

Please sign in to comment.