Hi. I'm quite new to programming and i having a problem right now figuring out some methods on my program. anyways i cant figure out how to work out my touchmove event. I want to move a uiimage in x direction or y direction depending on the direction of the touchmove event but i want the movement to be in a grid type movement like by 20 pixels. i use touchbegan to check what image is touch;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(image1.frame,location))
image1IsDragging = YES;
else
image2IsDragging=NO;
}
and i got stuck with my touchmoved event.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (image1IsDragging == YES) {
//stuck here on how to check the direction of the swipe and how to move in increment of 20 pixs
}
}
I was thinking of getting the round-off of the distance like;
float distanceX = newLocation.x - firstTouch.x;
but i dont know how to do it. Hope someone could lend me some help. thanks.