当前位置:编程学习 > wap >>

cocos2d 多手势

CGPoint begen = [touch locationInView: [touch view]];

    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) {//多点触摸 

       

        CGPoint touch0_point = [[[allTouches allObjects] objectAtIndex:0] locationInView: [touch view]];

        CGPoint touch1_point = [[[allTouches allObjects] objectAtIndex:1] locationInView: [touch view]];

       

touchSpriteB_.position = touch0_point;

touchSpriteA_.position = touch1_point;

        NSLog(@"两点触摸\n%f---%f",touch0_point.x,touch1_point.x);


       

 

补充:移动开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,