cocos2d-iPhone function to check if the touch input was zoom out
-(BOOL)wasZoomOut:(NSSet *)touches :(UIEvent *)event { NSSet *allTouches = [event allTouches]; if(2 != [allTouches count]) return FALSE; UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; CGPoint start1 = [touch previousLocationInView:[touch view]]; CGPoint end1 = [touch locationInView:[touch view]]; start1 = _icRotateRealWorld(start1); end1 = _icRotateRealWorld(end1); touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint start2 = [touch previousLocationInView:[touch view]]; CGPoint end2 = [touch locationInView:[touch view]]; start2 = _icRotateRealWorld(start2); end2 = _icRotateRealWorld(end2); float initialDistance = icDistanceBetweenTwoPoints(start1, start2); float endDistance = icDistanceBetweenTwoPoints(end1, end2); if(endDistance < initialDistance) { return TRUE; } return FALSE; }
Log in to answer.
leothenerd 5:54 pm on January 3, 2010