我想知道NST触及ccTouchesBegan是否可以包含多个触摸。 我做了一些测试,触摸次数总是1次。
任何人都可以证实这一点?如果只有一次触摸,为什么会有一套?
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
答案 0 :(得分:1)
检查出来
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *set = [event allTouches];
if (set.count == 1) { //first touch
}
if (set.count == 2) { //second touch
} //etc.
答案 1 :(得分:1)
在这里,你好友。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch =[[[event allTouches] allObjects] lastObject];
//NSLog(@"touchesBegan ...");
switch ([touch tapCount])
{
case 1:
[self performSelector:@selector(oneTap) withObject:nil afterDelay:.5];
break;
case 2:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(oneTap) object:nil];
[self performSelector:@selector(twoTaps) withObject:nil afterDelay:.5];
break;
case 3:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(twoTaps) object:nil];
[self performSelector:@selector(threeTaps) withObject:nil afterDelay:.5];
break;
default:
break;
}
};
- (IBAction)oneTap
{
NSLog(@"oneTap ...");
}
- (IBAction)twoTaps
{
NSLog(@"twoTaps ...");
}
- (IBAction)threeTaps
{
NSLog(@"threeTaps ...");
}