UITapGestureRecognizer を使用して、画面上の指の x 座標と y 座標を取得します。どのようにできるのか?
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
タッチ ポイントを取得する最良の方法の 1 つは、以下に示すように 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 に答える