Iphone 使用TapGestureRecognitor获取坐标x和y
我使用UITapGestureRecognitor在屏幕上导出手指的x和y坐标。我该怎么办 获取接触点的最佳方法之一是从如下所示的CCTouchMoved中全局声明变量,以便您也可以将其用于其他人Iphone 使用TapGestureRecognitor获取坐标x和y,iphone,objective-c,geometry,core-graphics,uitapgesturerecognizer,Iphone,Objective C,Geometry,Core Graphics,Uitapgesturerecognizer,我使用UITapGestureRecognitor在屏幕上导出手指的x和y坐标。我该怎么办 获取接触点的最佳方法之一是从如下所示的CCTouchMoved中全局声明变量,以便您也可以将其用于其他人 -(void) handleTapGesture:(UIGestureRecognizer *) sender { CGPoint tapPoint = [sender locationInView:someView]; int tapX = (int) tapPoint.x;
-(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);
}
-(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);
在头文件中声明“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);
}
-(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);