我正在使用Cocos2D进行游戏开发。这是我最近遇到的情况。
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"Number of touches %d",touches.count);
}
我在iPod touch上运行我的示例应用程序并用两根手指触摸屏幕。我第一次触摸时,日志显示“触摸次数2”,但在第一次触摸后,无论触摸多少手指,我都会得到“触摸次数1”。
我也有点击计数的问题。如果我NSLog点击计数并触摸屏幕,我得到以下输出:
The tap count is 1
The tap count is 2
The tap count is 3
And so on.....
当我三次点击屏幕而不是获得1,2,3时,我不应该只获得“点按数3”吗?它会记录所有的水龙头,直到最后一个。
我所知道并确定接触的是:
我需要这两种行为才能正常工作,因为我会根据触摸次数和点击次数决定做什么。
答案 0 :(得分:2)
NSArray * touchArray = [touches allObjects];
NSLog(@"Number of touches %d",touchArray.count);
上面的代码是当前有效的触摸次数
NSSet *touches= [event allTouches];
您将获得一次触发该方法的次数,如双指点按或三指点击