如何区分单指tap和双指tap呢
直接上代码 若使用UIKit请自行修改函数名称 以下是cocos2d代码
//GameTouches = [[NSMutableSet alloc]init];
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (touches.count ==1) {
[GameTouches addObject:[touches anyObject]];
if(GameTouches.allObjects.count == 2)
{
[self jump];//双指tap
[GameTouches removeAllObjects];
}
}else
{
[self jump];//多指tap
}
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (GameTouches.allObjects.count==1) {
[self fire];//单指tap
}
[GameTouches removeAllObjects];
}
- (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self ccTouchesEnded:touches withEvent:event];
}