これは、plist でのデータの取得に関する最初のクエリに対するフォローアップの質問です。現在、ランダムな画像呼び出しを使用して、ビューで行われたユーザーのタッチを検出することができました (phytonquick のおかげです)。
CGPoint currentTouchLocation = [currentTouch locationInView:self];
ユーザーがビュー内のランダム画像に触れて得た値と、ユーザーが触れたランダム画像と同じ名前の plist データ内に保存された値を比較する方法に問題があります。接触距離を計算する方法を知っているので、ヒットポイントを調整できます。
-(CGFloat) distanceBetween: (CGPoint) point1 and: (CGPoint)point2
NSMutableDictionary *????? = [self loadDictionaryFromPList: @"?????"];
NSNumber *1stXCoordinate = [????? objectForKey:@"1stXCoordinate"];
NSNumber *1stYCoordinate = [????? objectForKey:@"1stYCoordinate"];
if (1stXCoordinate && 1stYCoordinate)
{
CGPoint 1stTouchLocation = CGPointMake([lastXCoordinate floatValue], [lastYCoordinate floatValue]);
CGFloat distanceBetweenTouches = [self distanceBetween: currentTouchLocation and: 1stTouchLocation];
if (distanceBetweenTouches < 20)
{
// do something here
NSLog(@"You hit it.");
}
}
また、plist データをどのように作成すればよいかわかりません。私はそれのサンプル(「iphone 3 dev」など)でいくつかの本を読みましたが、私が見たサンプルのほとんどがテーブルビューの目的である場合、特にそれを理解することはできません. これは私が私のplistをレイアウトする方法です:
randImage <-- callout array
p1.jpg <-- image represented by array
tap1 <-- Array
item 1 - x1 coordinate <-- Number
item 2 - y1 coordinate <-- Number
item 3 - x2 coordinate <-- Number
item 4 - y2 coordinate <-- Number
item 5 - x3 coordinate <-- Number
item 6 - y3 coordinate <-- Number
tap2 <-- Array
item 1 - x1 coordinate <-- Number
item 2 - y1 coordinate <-- Number
item 3 - x2 coordinate <-- Number
item 4 - y2 coordinate <-- Number
p2.jpg <-- image represented by array
tap1
item 1....etc
誰かがこれを行う方法について正しい道を教えてください。ありがとうございました。