iOS:ccTouchesBegan可以包含多个触控吗?

时间:2013-06-23 16:57:24

标签: ios cocos2d-iphone touch ontouchevent

我想知道NST触及ccTouchesBegan是否可以包含多个触摸。 我做了一些测试,触摸次数总是1次。

任何人都可以证实这一点?如果只有一次触摸,为什么会有一套?

-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

2 个答案:

答案 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 ...");

}