作者yeah200077 (爹卡路洽)
看板MacDev
标题[问题] multiTouch疑问
时间Sat Aug 18 17:52:33 2012
最近有个需求是要在同一个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