cocos2d多点触摸

转载自:http://fengmm521.blog.163.com/blog/static/2509135820123177468240/

第一步,在applicationDidFinishLaunching方法加入:

 

[viewController.view setMultipleTouchEnabled:YES];//开启多点触摸支持

 

第二步:

 

//监听首次触发事件      - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event   {       NSSet *allTouches = [event allTouches];//获得所有触摸点               int count = [[allTouches allObjects] count];//当前触摸点数量,单点触摸为1.        if (count == 1) {//单点触摸            UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];//获得第一个触摸点            switch ([touch1 tapCount]) {//判断是单击还是双击                case 1:                   NSLog(@"单击\n");                   break;               case 2:                   NSLog(@"双击\n");                   break;           }       }else if (count == 2) {//多点触摸            //        }              return YES;   }    

也就是通过event参数得到一个NSSet,这个NSSet保存了所有的触摸点。

每次双击事件之前都有一个单击时间。


posted on 2012-08-19 22:38  yang3wei  阅读(107)  评论(0编辑  收藏  举报