我使用UITapGestureRecognizer在屏幕上导出手指的x和y坐标。我能怎么做?
答案 0 :(得分:3)
-(void) handleTapGesture:(UIGestureRecognizer *) sender {
CGPoint tapPoint = [sender locationInView:someView];
int tapX = (int) tapPoint.x;
int tapY = (int) tapPoint.y;
NSLog(@"TAPPED X:%d Y:%d", tapX, tapY);
}
答案 1 :(得分:0)
获得触摸点的最佳方法之一是来自CCTouchMoved,如下所示,并全局声明该变量,以便您也可以将其用于其他人。
声明“CGPoint * touchLocation;”在您的头文件中。
-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event{
//get locations of touch
touchLocation = [touch locationInView:[touch view]];
NSLog(@"Touch Points are %f, %f", touchLocation.x, touchLocation.y);
}