我使用 UITapGestureRecognizer 导出屏幕上手指的 x 和 y 坐标。我能怎么做?
问问题
341 次
2 回答
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);
}
于 2012-05-22T08:02:18.027 回答
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);
}
于 2012-05-22T08:26:56.620 回答