views:

117

answers:

1

Hi, I got the coordinates of touchesBegan and touchesEnded. But in touchesMoved can I get all the coordinates of the touch from touchesBegan to touchesEnded. I mean that when I put finger on screen and dragged to some position and then I lifted it. So, can I get all the coordinates of the starting position to end position. If possible, how I can I get them ?

+2  A: 

TouchesMoved gets called whenever there is movement on the touch. If you want an array of all points you'll need to add them to a mutable array every time touchesMoved is called.

- (void) touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint tappedPt = [[touches anyObject] locationInView: self];
    int     xPos = tappedPt.x;
    int     yPos = tappedPt.y;
    // do something with xPos and yPos like add them to an array
}
rein