[問題] multiTouch疑問
最近有個需求是要在同一個View上偵測多點觸碰的各別事件
我有兩個觸碰點 P1、P2
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
int count = [[touches allObjects] count];
CGPoint p1 = [[[touches allObjects] objectAtIndex:0]locationInView:self.view];
CGPoint p2 = [[[touches allObjects] objectAtIndex:1]locationInView:self.view];
}
在touchBegan時是沒什麼問題,在touchesMoved時假設兩點同時移動中
然後P1暫時停止動作(touch沒放開),P2繼續Move...
在[[touches allObjects] objectAtIndex:0] 此時抓到就會變成P2的touch
這邊就不合需求了
不知道有沒有好方法可以將兩者的事件拆開,或是把個別的touch began加上Tag
然後在move就可以依據tag判斷現在是哪個touch在動
類似APP 的cut the rope 用多指切斷繩子的功能,各切各的,互不影響
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.160.46.250